{"id":16557591,"url":"https://github.com/mpratt/relativetime","last_synced_at":"2025-03-17T16:11:09.819Z","repository":{"id":10777135,"uuid":"13043386","full_name":"mpratt/RelativeTime","owner":"mpratt","description":"A library that calculates the time difference between two dates and returns the result in words (Example: 5 minutes ago or 5 Minutes left). The library supports other languages aswell like Spanish and German.","archived":false,"fork":false,"pushed_at":"2024-08-16T04:10:19.000Z","size":86,"stargazers_count":31,"open_issues_count":0,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-02T13:11:17.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/mpratt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-09-23T18:19:07.000Z","updated_at":"2024-11-01T16:05:44.000Z","dependencies_parsed_at":"2024-06-18T18:14:12.821Z","dependency_job_id":"47547a08-3f49-4f64-8217-22da805b5b99","html_url":"https://github.com/mpratt/RelativeTime","commit_stats":{"total_commits":58,"total_committers":14,"mean_commits":4.142857142857143,"dds":0.5517241379310345,"last_synced_commit":"bb3f309ad7bddf531451a2b9d0da1d012e15a099"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpratt%2FRelativeTime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpratt%2FRelativeTime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpratt%2FRelativeTime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpratt%2FRelativeTime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpratt","download_url":"https://codeload.github.com/mpratt/RelativeTime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066180,"owners_count":20392406,"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":[],"created_at":"2024-10-11T20:07:54.750Z","updated_at":"2025-03-17T16:11:09.795Z","avatar_url":"https://github.com/mpratt.png","language":"PHP","funding_links":["https://paypal.me/mtpratt"],"categories":[],"sub_categories":[],"readme":"# RelativeTime\n\n[![Build Status](https://github.com/mpratt/RelativeTime/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/mpratt/RelativeTime/actions)\n[![Total Downloads](https://img.shields.io/packagist/dt/mpratt/relativetime.svg)](https://packagist.org/packages/mpratt/relativetime)\n[![Monthly Downloads](https://img.shields.io/packagist/dm/mpratt/relativetime)](https://packagist.org/packages/mpratt/relativetime)\n[![Latest Stable Version](https://img.shields.io/packagist/v/mpratt/relativetime.svg)](https://packagist.org/packages/mpratt/relativetime)\n\n[![Support via PayPal](https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg)](https://paypal.me/mtpratt)\n\nRelativeTime is a lightweight and easy to use library that helps you calculate the time difference between two dates and returns the result in words\n(like, 5 minutes ago or 5 minutes left). The library supports other languages as well like `Spanish`, `PortugueseBR`, `French`, `Czech`, `Russian`,\n`SimplifiedChinese`, `Swedish` and `German`\n\nIt uses the standard \\DateTime() and \\DateInterval() classes found in modern PHP versions. For more information, please read the `Usage` section of\nthis README.\n\n## Requirements\n\n- PHP \u003e= 5.3 (Tested only on PHP +7.3)\n\n### Installation\n\n#### Install with Composer\n\nIf you're using [Composer](https://github.com/composer/composer) to manage\ndependencies, you can use this library by creating a composer.json file and adding this:\n\n    {\n        \"require\": {\n            \"mpratt/relativetime\": \"~1.0\"\n        }\n    }\n\nSave it and run `composer.phar install`\n\n#### Standalone Installation (without Composer)\n\nDownload the latest release or clone this repository, place the `Lib/RelativeTime` directory somewhere in your project. Afterwards, you only need to include\nthe included `Autoload.php` file.\n\n```php\n    require '/path/to/RelativeTime/Autoload.php';\n\n    use RelativeTime\\RelativeTime;\n\n    $relativeTime = new RelativeTime();\n```\n\nOr if you already have PSR-0 compliant autoloader, you just need to register RelativeTime:\n\n```php\n    $loader-\u003eregisterNamespace('RelativeTime', 'path/to/RelativeTime');\n```\n\n#### Usage\n\nMost of the times you are going to need the `convert($fromDate, $toDate)` method.\n\n```php\n\n    use RelativeTime\\RelativeTime;\n\n    $relativeTime = new RelativeTime();\n    echo $relativeTime-\u003econvert('2010-09-05', '2010-03-30');\n    // 5 months, 6 days ago\n\n    $relativeTime = new RelativeTime();\n    echo $relativeTime-\u003econvert('2012-03-05', '2013/02/05');\n    // 11 months left\n```\n\nThere are 2 other useful methods `timeAgo($date)` and `timeLeft($date)`, that calculate the time since/until\nthe current date/time.\n\n```php\n    use RelativeTime\\RelativeTime;\n\n    // Asumming Today is the 2013-09-23 17:23:47\n\n\n    $relativeTime = new RelativeTime();\n    echo $relativeTime-\u003etimeAgo('2012-08-29 06:00');\n    // 1 year, 25 days, 16 hours, 23 minutes, 13 seconds ago\n\n    $relativeTime = new RelativeTime();\n    echo $relativeTime-\u003etimeLeft('2013-10-31 01:00:05');\n    // 1 month, 7 days, 2 hours, 36 minutes, 52 seconds left\n```\n\n#### Configuration Options\n\nThe main object accepts an array with configuration directives\n\n```php\n\n    use RelativeTime\\RelativeTime;\n\n    $config = array(\n        'language' =\u003e '\\RelativeTime\\Languages\\English',\n        'separator' =\u003e ', ',\n        'suffix' =\u003e true,\n        'truncate' =\u003e 0,\n        'use_weeks' =\u003e false,\n    );\n\n    $relativeTime = new RelativeTime($config);\n```\n\n| Directive |                                                                                                   Definition                                                                                                   |\n| --------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |\n| language  | The language to be used, for example `English`, `Spanish`, `PortugueseBR`, `French`, `Czech`, `Russian`, `SimplifiedChinese`, `Swedish` or `German` are supported. Even The instantiated object is allowed, as in `new \\RelativeTime\\Languages\\English()` |\n| separator |                                                                               The separator between time units. `, ` by default.                                                                               |\n| truncate  |                                                           The number of units you want to display. By default it displays all of the available ones.                                                           |\n| suffix    |                                                                            Whether or not to append the `.... ago` or `..... left`                                                                             |\n| use_weeks | By default is set to false. When set to true it will include week numbers too.                                                                                                                                 |\n\n## Author\n\nMichael Pratt - \u003cyo@michael-pratt.com\u003e - \u003chttp://www.michael-pratt.com\u003e\nSee also the list of [contributors](https://github.com/mpratt/relativetime/contributors) which participated in this project.\n\nIf you like this library, it has been useful to you and want to support me, you can do it via paypal.\n\n[![Support via PayPal](https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg)](https://paypal.me/mtpratt)\n\n## License\n\nRelativeTime is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpratt%2Frelativetime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpratt%2Frelativetime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpratt%2Frelativetime/lists"}