{"id":25198273,"url":"https://github.com/nixrajput/get_time_ago","last_synced_at":"2025-05-08T23:29:52.209Z","repository":{"id":44738259,"uuid":"294532581","full_name":"nixrajput/get_time_ago","owner":"nixrajput","description":"A Dart package that converts and formats `DateTime` objects into human-readable 'time ago' strings, such as '20 seconds ago', 'a minute ago', or '7 hours ago'.","archived":false,"fork":false,"pushed_at":"2025-03-11T08:22:13.000Z","size":7124,"stargazers_count":25,"open_issues_count":4,"forks_count":27,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T15:10:05.150Z","etag":null,"topics":["collaborate","dart","datetime","datetime-format","datetime-to-string","flutter","flutter-packages","flutterdev","get-time-ago","get-time-ago-flutter","nixlab","nixlab-packages","nixrajput","nixrajput-github","packages","pub","timago","time-ago","time-ago-flutter"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/get_time_ago","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nixrajput.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"nixrajput"}},"created_at":"2020-09-10T22:05:08.000Z","updated_at":"2025-03-11T08:20:29.000Z","dependencies_parsed_at":"2023-02-14T09:00:44.249Z","dependency_job_id":"7060078f-79a1-4909-b948-2a2654b5fff9","html_url":"https://github.com/nixrajput/get_time_ago","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixrajput%2Fget_time_ago","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixrajput%2Fget_time_ago/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixrajput%2Fget_time_ago/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixrajput%2Fget_time_ago/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nixrajput","download_url":"https://codeload.github.com/nixrajput/get_time_ago/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253163077,"owners_count":21864021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collaborate","dart","datetime","datetime-format","datetime-to-string","flutter","flutter-packages","flutterdev","get-time-ago","get-time-ago-flutter","nixlab","nixlab-packages","nixrajput","nixrajput-github","packages","pub","timago","time-ago","time-ago-flutter"],"created_at":"2025-02-10T03:00:45.879Z","updated_at":"2025-05-08T23:29:52.196Z","avatar_url":"https://github.com/nixrajput.png","language":"Dart","funding_links":["https://github.com/sponsors/nixrajput","https://ko-fi.com/nixrajput","https://www.buymeacoffee.com/nixrajput"],"categories":[],"sub_categories":[],"readme":"# get_time_ago\r\n\r\nA Dart package that converts and formats `DateTime` objects into human-readable 'time ago' strings, such as '20 seconds ago', 'a minute ago', or '7 hours ago'. This package provides an easy way to display relative time differences in your Flutter or Dart applications. It supports various time units (seconds, minutes, hours, days, etc.) and automatically adjusts the format based on how recent the event occurred. Ideal for displaying timestamps in news feeds, social media posts, or chat messages.\r\n\r\n[![pub package](https://img.shields.io/pub/v/get_time_ago.svg?label=Version\u0026style=flat)][pub]\r\n[![Stars](https://img.shields.io/github/stars/nixrajput/get_time_ago?label=Stars\u0026style=flat)][repo]\r\n[![Forks](https://img.shields.io/github/forks/nixrajput/get_time_ago?label=Forks\u0026style=flat)][repo]\r\n[![Watchers](https://img.shields.io/github/watchers/nixrajput/get_time_ago?label=Watchers\u0026style=flat)][repo]\r\n[![Contributors](https://img.shields.io/github/contributors/nixrajput/get_time_ago?label=Contributors\u0026style=flat)][repo]\r\n\r\n[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/nixrajput/get_time_ago?label=Code+Size\u0026style=flat)][repo]\r\n[![GitHub repo size](https://img.shields.io/github/repo-size/nixrajput/get_time_ago?label=Repo+Size\u0026style=flat)][repo]\r\n[![GitHub language count](https://img.shields.io/github/languages/count/nixrajput/get_time_ago?label=Languages\u0026style=flat)][repo]\r\n[![GitHub top language](https://img.shields.io/github/languages/top/nixrajput/get_time_ago?label=Top+Language\u0026style=flat)][repo]\r\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/nixrajput?label=Sponsors\u0026style=flat)][repo]\r\n\r\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/nixrajput/get_time_ago?label=Latest+Release\u0026style=flat)][releases]\r\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/nixrajput/get_time_ago?label=Latest+Release\u0026style=flat)][releases]\r\n[![GitHub last commit](https://img.shields.io/github/last-commit/nixrajput/get_time_ago?label=Last+Commit\u0026style=flat)][repo]\r\n[![GitHub issues](https://img.shields.io/github/issues/nixrajput/get_time_ago?label=Issues\u0026style=flat)][issues]\r\n[![GitHub pull requests](https://img.shields.io/github/issues-pr/nixrajput/get_time_ago?label=Pull+Requests\u0026style=flat)][pulls]\r\n[![GitHub License](https://img.shields.io/github/license/nixrajput/get_time_ago?label=Licence\u0026style=flat)][license]\r\n\r\n## Table of Contents\r\n\r\n- [get\\_time\\_ago](#get_time_ago)\r\n  - [Table of Contents](#table-of-contents)\r\n  - [Breaking Changes for the Version ^2.0.0](#breaking-changes-for-the-version-200)\r\n    - [1. Added `justNow` Method in `Messages` Interface](#1-added-justnow-method-in-messages-interface)\r\n    - [Impact on Custom Implementations:](#impact-on-custom-implementations)\r\n    - [Example of Custom Locale Update:](#example-of-custom-locale-update)\r\n  - [Demo](#demo)\r\n  - [Installation](#installation)\r\n  - [Usage](#usage)\r\n    - [Formatting String as `get_time_ago`](#formatting-string-as-get_time_ago)\r\n    - [Setting default locale](#setting-default-locale)\r\n    - [Setting Custom Locale \\\u0026 Messages](#setting-custom-locale--messages)\r\n  - [Supported Languages](#supported-languages)\r\n  - [Contributing](#contributing)\r\n  - [License](#license)\r\n  - [Contributors](#contributors)\r\n  - [Support My Work](#support-my-work)\r\n  - [Connect With Me](#connect-with-me)\r\n  - [Activities](#activities)\r\n\r\n## Breaking Changes for the Version ^2.0.0\r\n\r\n### 1. Added `justNow` Method in `Messages` Interface\r\n\r\nIn version 2.0.0, a new method `justNow(int seconds)` has been added to the `Messages` interface. This method is responsible for providing a custom message when the elapsed time is less than 15 seconds.\r\n\r\n### Impact on Custom Implementations:\r\n\r\nIf you have implemented any custom locales by extending the `Messages` interface, you will need to update your implementation to include the new `justNow` method. Failing to implement this method will result in compilation errors.\r\n\r\n### Example of Custom Locale Update:\r\n\r\nBefore:\r\n\r\n```dart\r\nclass MyCustomMessages implements Messages {\r\n  @override\r\n  String prefixAgo() =\u003e '';\r\n\r\n  @override\r\n  String suffixAgo() =\u003e 'ago';\r\n\r\n  // Implement the other methods here...\r\n}\r\n```\r\n\r\nAfter (Version 2.0.0):\r\n\r\n```dart\r\nclass MyCustomMessages implements Messages {\r\n  @override\r\n  String prefixAgo() =\u003e '';\r\n\r\n  @override\r\n  String suffixAgo() =\u003e 'ago';\r\n\r\n  @override\r\n  String justNow(int seconds) =\u003e 'just now';  // New method\r\n\r\n  // Implement the other methods here...\r\n}\r\n```\r\n\r\nThis section explains the breaking change, the impact it has on custom implementations, and provides an example of how to update existing code to comply with the new changes in version ^2.0.0.\r\n\r\n## Demo\r\n\r\n\u003ch3\u003e\r\n\u003ca href=\"https://nixrajput.github.io/get_time_ago\" target=\"_blank\"\u003e\r\n  Click here to experience the demo in a Web App\r\n\u003c/a\u003e\r\n\u003c/h3\u003e\r\n\r\n## Installation\r\n\r\nAdd `get_time_ago` as a dependency in your `pubspec.yaml` file.\r\n\r\n```yaml\r\ndependencies:\r\n  get_time_ago: ^latest_version\r\n```\r\n\r\n## Usage\r\n\r\nFormat any `DateTime` object into `get_time_ago` format by following steps:\r\n\r\n```dart\r\n// Import the plugin\r\nimport 'package:get_time_ago/get_time_ago.dart';\r\n\r\n// Pass DateTime object as argument in the method\r\nvar _dateTime = DateTime.now().subtract(const Duration(minutes: 10)); // [DateTime] object\r\nprint(GetTimeAgo.parse(_dateTime)); // 10 minutes ago\r\n\r\n// Formatting with locale\r\nprint(GetTimeAgo.parse(_dateTime, locale:'es')); // hace 10 minutos\r\n```\r\n\r\n### Formatting String as `get_time_ago`\r\n\r\nIf you have saved a `DateTime` object as a String into a variable, database or cloud, then you have\r\nto first convert the String into `DateTime` object and then pass it as argument in `parse` method\r\nof `get_time_ago` plugin to format it into `get_time_ago` format by following steps:\r\n\r\n```dart\r\n// Import the plugin\r\nimport 'package:get_time_ago/get_time_ago.dart';\r\n\r\nvar _timestamp = '2021-05-10 05:21:37.712498'; // [DateTime] formatted as String.\r\nvar _convertedTimestamp = DateTime.parse(_timestamp); // Converting into [DateTime] object\r\nvar result = GetTimeAgo.parse(_convertedTimestamp);\r\nprint(result);\r\n```\r\n\r\n### Setting default locale\r\n\r\nIf you want to change your default `locale`, then call `setDefaultLocale` method and pass\r\nthe `locale` code as the argument.\r\n\r\n```dart\r\n// Import the plugin\r\nimport 'package:get_time_ago/get_time_ago.dart';\r\n\r\n@override\r\nvoid initState() {\r\n  super.initState();\r\n  GetTimeAgo.setDefaultLocale('fr'); // Sets the default locale to French\r\n}\r\n```\r\n\r\n### Setting Custom Locale \u0026 Messages\r\n\r\nImplementing and Adding Custom Messages\r\n\r\n```dart\r\nclass CustomMessages implements Messages {\r\n  /// Prefix added before the time message.\r\n  @override\r\n  String prefixAgo() =\u003e '';\r\n\r\n  /// Suffix added after the time message.\r\n  @override\r\n  String suffixAgo() =\u003e 'ago';\r\n\r\n  /// Message when the elapsed time is less than 15 seconds.\r\n  @override\r\n  String justNow(int seconds) =\u003e 'just now';\r\n\r\n  /// Message for when the elapsed time is less than a minute.\r\n  @override\r\n  String secsAgo(int seconds) =\u003e '$seconds seconds';\r\n\r\n  /// Message for when the elapsed time is about a minute.\r\n  @override\r\n  String minAgo(int minutes) =\u003e 'a minute';\r\n\r\n  /// Message for when the elapsed time is in minutes.\r\n  @override\r\n  String minsAgo(int minutes) =\u003e '$minutes minutes';\r\n\r\n  /// Message for when the elapsed time is about an hour.\r\n  @override\r\n  String hourAgo(int minutes) =\u003e 'an hour';\r\n\r\n  /// Message for when the elapsed time is in hours.\r\n  @override\r\n  String hoursAgo(int hours) =\u003e '$hours hours';\r\n\r\n  /// Message for when the elapsed time is about a day.\r\n  @override\r\n  String dayAgo(int hours) =\u003e 'a day';\r\n\r\n  /// Message for when the elapsed time is in days.\r\n  @override\r\n  String daysAgo(int days) =\u003e '$days days';\r\n\r\n  /// Word separator to be used when joining the parts of the message.\r\n  @override\r\n  String wordSeparator() =\u003e ' ';\r\n}\r\n```\r\n\r\nOverriding `en` Locale Messages with Custom Messages\r\n\r\n```dart\r\nGetTimeAgo.setCustomLocaleMessages('en', CustomMessages());\r\n```\r\n\r\n## Supported Languages\r\n\r\n- Arabic\r\n- English\r\n- Spanish\r\n- Persian (Farsi)\r\n- French\r\n- Hindi\r\n- Portuguese (Brazil)\r\n- Portuguese (Brazil alternate)\r\n- Simplified Chinese\r\n- Traditional Chinese\r\n- Japanese\r\n- Occitan\r\n- Korean\r\n- German\r\n- Indonesian\r\n- Turkish\r\n- Urdu\r\n- Vietnamese\r\n- Romanian\r\n- Dutch\r\n- Nepali\r\n- Italian\r\n- Open to accept PR for adding more languages\r\n\r\n## Contributing\r\n\r\nIf you would like to contribute to this project, feel free to fork the repository, make your changes, and submit a pull request. Please follow the guidelines in the [CONTRIBUTING.md](CONTRIBUTING.md) file.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Contributors\r\n\r\n\u003ca href=\"https://github.com/nixrajput/get_time_ago/graphs/contributors\" target=\"_blank\"\u003e\r\n  \u003cimg src=\"https://contrib.rocks/image?repo=nixrajput/get_time_ago\" /\u003e\r\n\u003c/a\u003e\r\n\r\nMade with [contrib.rocks](https://contrib.rocks).\r\n\r\n## Support My Work\r\n\r\nYour support helps me dedicate more time to developing high-quality, impactful projects in the open-source community. Sponsor me, and together, let’s bring even more innovation to life!\r\n\r\n[![Sponsor](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://github.com/sponsors/nixrajput)\r\n\r\n[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/nixrajput)\r\n\r\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/nixrajput)\r\n\r\n## Connect With Me\r\n\r\n[![GitHub: nixrajput](https://img.shields.io/badge/nixrajput-EFF7F6?logo=GitHub\u0026logoColor=333\u0026link=https://www.github.com/nixrajput)][github]\r\n[![Linkedin: nixrajput](https://img.shields.io/badge/nixrajput-EFF7F6?logo=Linkedin\u0026logoColor=333\u0026link=https://www.linkedin.com/in/nixrajput)][linkedin]\r\n[![Instagram: nixrajput](https://img.shields.io/badge/nixrajput-EFF7F6?logo=Instagram\u0026logoColor=333\u0026link=https://www.instagram.com/nixrajput)][instagram]\r\n[![Twitter: nixrajput07](https://img.shields.io/badge/nixrajput07-EFF7F6?logo=X\u0026logoColor=333\u0026link=https://x.com/nixrajput07)][twitter]\r\n[![Telegram: nixrajput](https://img.shields.io/badge/nixrajput-EFF7F6?logo=Telegram\u0026logoColor=333\u0026link=https://telegram.me/nixrajput)][telegram]\r\n[![Gmail: nkr.nikhi.nkr@gmail.com](https://img.shields.io/badge/nkr.nikhil.nkr@gmail.com-EFF7F6?logo=Gmail\u0026logoColor=333\u0026link=mailto:nkr.nikhil.nkr@gmail.com)][gmail]\r\n\r\n## Activities\r\n\r\n![Alt](https://repobeats.axiom.co/api/embed/cbde7baa03c95d2e3261af1fa679d94570341b08.svg \"Repobeats analytics image\")\r\n\r\n[pub]: https://pub.dev/packages/get_time_ago\r\n[github]: https://github.com/nixrajput\r\n[telegram]: https://telegram.me/nixrajput\r\n[twitter]: https://twitter.com/nixrajput07\r\n[instagram]: https://instagram.com/nixrajput\r\n[linkedin]: https://linkedin.com/in/nixrajput\r\n[gmail]: mailto:nkr.nikhil.nkr@gmail.com\r\n[releases]: https://github.com/nixrajput/get_time_ago/releases\r\n[repo]: https://github.com/nixrajput/get_time_ago\r\n[issues]: https://github.com/nixrajput/get_time_ago/issues\r\n[license]: https://github.com/nixrajput/get_time_ago/blob/master/LICENSE\r\n[pulls]: https://github.com/nixrajput/get_time_ago/pulls\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixrajput%2Fget_time_ago","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnixrajput%2Fget_time_ago","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixrajput%2Fget_time_ago/lists"}