{"id":15296376,"url":"https://github.com/garyjones/daterange","last_synced_at":"2026-01-05T13:54:13.424Z","repository":{"id":62508786,"uuid":"133713720","full_name":"GaryJones/daterange","owner":"GaryJones","description":"PHP: Display a range of dates, with consolidated time parts.","archived":false,"fork":false,"pushed_at":"2018-06-03T18:40:16.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T05:43:40.427Z","etag":null,"topics":["date","date-range","php71"],"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/GaryJones.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-16T19:27:06.000Z","updated_at":"2021-05-08T00:08:49.000Z","dependencies_parsed_at":"2022-11-02T10:16:42.069Z","dependency_job_id":null,"html_url":"https://github.com/GaryJones/daterange","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaryJones%2Fdaterange","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaryJones%2Fdaterange/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaryJones%2Fdaterange/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaryJones%2Fdaterange/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GaryJones","download_url":"https://codeload.github.com/GaryJones/daterange/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245407755,"owners_count":20610232,"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":["date","date-range","php71"],"created_at":"2024-09-30T18:10:16.811Z","updated_at":"2026-01-05T13:54:13.394Z","avatar_url":"https://github.com/GaryJones.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gamajo Date Range\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/gamajo/daterange.svg)](https://packagist.org/packages/gamajo/daterange)\n[![Total Downloads](https://img.shields.io/packagist/dt/gamajo/daterange.svg)](https://packagist.org/packages/gamajo/daterange)\n[![Latest Unstable Version](https://img.shields.io/packagist/vpre/gamajo/daterange.svg)](https://packagist.org/packages/gamajo/daterange)\n[![License](https://img.shields.io/packagist/l/gamajo/daterange.svg)](https://packagist.org/packages/gamajo/daterange)\n\nDisplay a range of dates, with consolidated time parts.\n\n## Table Of Contents\n\n* [Installation](#installation)\n* [Basic Usage](#basic-usage)\n* [Advanced Usage](#advanced-usage)\n* [Contributing](#contributing)\n* [License](#license)\n\n## Installation\n\nThe best way to use this package is through Composer:\n\n```BASH\ncomposer require gamajo/daterange\n```\n\n## Basic Usage\n\nCreate an instance of the `DateRange` class, with `DateTimeImmutable` or `DateTime` start and end date-time objects as arguments. Then choose the format to use as the end date output. The start date will only display the time parts that are not duplicated.\n\n```php\n$dateRange = new DateRange(\n    new DateTimeImmutable('23rd June 18 14:00'),\n    new DateTimeImmutable('2018-06-23T15:00')\n);\necho $dateRange-\u003eformat('H:i d M Y'); // 14:00 – 15:00 23 Jun 2018\n```\n\nIf the formatted date would be the same start and end date, only a single date is displayed:\n\n```php\n$dateRange = new DateRange(\n    new DateTimeImmutable('23rd June 18 14:00'),\n    new DateTimeImmutable('2018-06-23T15:00')\n);\necho $dateRange-\u003eformat('jS M Y'); // 23rd Jun 2018\n```\n\n## Advanced Usage\n\n### Change Separator\n\nThe default separator between the start and end date, is a space, en-dash, space: `' – '`\n\nThis can be changed via the `changeSeparator()` method:\n\n```php\n$dateRange = new DateRange(\n    new DateTimeImmutable('23rd June 18 14:00'),\n    new DateTimeImmutable('2018-06-23T15:00')\n);\n$dateRange-\u003echangeSeparator(' to ');\necho 'From ', $dateRange-\u003eformat('H:i d M Y'); // From 14:00 to 15:00 23 Jun 2018\n```\n\n### Change Removable Delimiters\n\nThe consolidation and removal of some time parts may leave delimiters from the format:\n\n```php\n$dateRange = new DateRange(\n    new DateTimeImmutable('23rd June 18'),\n    new DateTimeImmutable('2018-06-24')\n);\necho $dateRange-\u003eformat('d·M·Y'); //  23·· – 24·Jun·2018\n```\n\nBe default, `/`, `-` and `.` are trimmed from the start date, but this can be amended with the `changeRemovableDelimiters()` method:\n\n```php\n$dateRange = new DateRange(\n    new DateTimeImmutable('23rd June 18'),\n    new DateTimeImmutable('2018-06-24')\n);\n$dateRange-\u003echangeRemovableDelimiters('·');\necho $dateRange-\u003eformat('d·M·Y'); //  23 – 24·Jun·2018\n```\n\n## Known Issues\n\nThese are known issues which need addressing before this package can be considered stable:\n\n- [Escaped characters are not handled correctly](https://github.com/GaryJones/daterange/issues/2)\n- [Duplicate time parts are not handled correctly](https://github.com/GaryJones/daterange/issues/3)\n- [Hours, minutes and seconds are not handled correctly](https://github.com/GaryJones/daterange/issues/4)\n\n\n## Contributing\n\nAll feedback, bug reports and pull requests are welcome.\n\n## License\n\nCopyright (c) 2018 Gary Jones, Gamajo\n\nThis code is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaryjones%2Fdaterange","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaryjones%2Fdaterange","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaryjones%2Fdaterange/lists"}