TimeAgo.Net
1.0.0
dotnet add package TimeAgo.Net --version 1.0.0
NuGet\Install-Package TimeAgo.Net -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TimeAgo.Net" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TimeAgo.Net" Version="1.0.0" />
<PackageReference Include="TimeAgo.Net" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TimeAgo.Net --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TimeAgo.Net, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TimeAgo.Net@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TimeAgo.Net&version=1.0.0
#tool nuget:?package=TimeAgo.Net&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TimeAgo.Net
Convert DateTime into human-readable strings like "5 minutes ago" or "in 2 days" with multilingual support.
Features
- Supports past & future tense (e.g.,
"5 minutes ago","in 3 hours") - Built-in support for English, Spanish, and Bengali
- Easily extendable to more languages
- Lightweight & dependency-free
- Works in .NET 6+ / .NET 8 projects
Installation
dotnet add package TimeAgo.Net
Usage Example
using System;
using TimeAgo.Net.Extensions;
class Program
{
static void Main()
{
// Ensure Bengali displays correctly
Console.OutputEncoding = System.Text.Encoding.UTF8;
// English examples
Console.WriteLine(DateTime.Now.AddMinutes(-5).ToTimeAgo("en")); // "5 minutes ago"
Console.WriteLine(DateTime.Now.AddMinutes(10).ToTimeAgo("en")); // "in 10 minutes"
// Spanish examples
Console.WriteLine(DateTime.Now.AddHours(-2).ToTimeAgo("es")); // "hace 2 horas"
Console.WriteLine(DateTime.Now.AddHours(3).ToTimeAgo("es")); // "en 3 horas"
// Bengali examples
Console.WriteLine(DateTime.Now.AddDays(-1).ToTimeAgo("bn")); // "১ দিন আগে"
Console.WriteLine(DateTime.Now.AddDays(3).ToTimeAgo("bn")); // "3 দিন পরে"
}
}
Extending to Other Languages
You can add additional languages by providing your own dictionary when creating the TimeAgoService:
var customResources = new Dictionary<string, Dictionary<string, string>>
{
["fr"] = new Dictionary<string, string>
{
{"Seconds_Singular_Past", "il y a 1 seconde"},
{"Seconds_Plural_Past", "il y a {0} secondes"},
{"Minutes_Singular_Past", "il y a 1 minute"},
{"Minutes_Plural_Past", "il y a {0} minutes"},
{"Seconds_Singular_Future", "dans 1 seconde"},
{"Seconds_Plural_Future", "dans {0} secondes"},
{"Minutes_Singular_Future", "dans 1 minute"},
{"Minutes_Plural_Future", "dans {0} minutes"},
// Add remaining keys for Hours, Days, Months, Years
}
};
var service = new TimeAgo.Net.Services.TimeAgoService(customResources);
Console.WriteLine(service.Format(DateTime.Now.AddMinutes(-5), "fr")); // "il y a 5 minutes"
License
This project is licensed under the MIT License.
Project URL
https://github.com/shahedbd/TimeAgo.Net
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 177 | 9/12/2025 |
Initial release with English, Spanish, and Bengali support for past and future tense.