PHPackages                             gamajo/daterange - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. gamajo/daterange

AbandonedArchivedLibrary

gamajo/daterange
================

Display a range of dates, with consolidated time parts.

0.2.0(7y ago)1231MITPHPPHP ^7.1

Since May 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/GaryJones/daterange)[ Packagist](https://packagist.org/packages/gamajo/daterange)[ Docs](https://github.com/GaryJones/date-range)[ RSS](/packages/gamajo-daterange/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (10)Versions (3)Used By (0)

Gamajo Date Range
=================

[](#gamajo-date-range)

[![Latest Stable Version](https://camo.githubusercontent.com/fee54d30d0e90eacc4dd90019e625c67a32b69fef8ebf812a0ee60e2b54db2da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67616d616a6f2f6461746572616e67652e737667)](https://packagist.org/packages/gamajo/daterange)[![Total Downloads](https://camo.githubusercontent.com/b797ea48f2617811bb808294c09a6a3732d7942254383a8d1931c59d28073610/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67616d616a6f2f6461746572616e67652e737667)](https://packagist.org/packages/gamajo/daterange)[![Latest Unstable Version](https://camo.githubusercontent.com/efb4c1376bd6e3af0dbe06da66926a8b5edc9e9353d81a1da21e8dbfab36fa26/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f67616d616a6f2f6461746572616e67652e737667)](https://packagist.org/packages/gamajo/daterange)[![License](https://camo.githubusercontent.com/ac7c1dde58e1fb397a785cf8dcccfdd581f985aa5f39f77692e50692266a6b36/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f67616d616a6f2f6461746572616e67652e737667)](https://packagist.org/packages/gamajo/daterange)

Display a range of dates, with consolidated time parts.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Advanced Usage](#advanced-usage)
- [Contributing](#contributing)
- [License](#license)

Installation
------------

[](#installation)

The best way to use this package is through Composer:

```
composer require gamajo/daterange
```

Basic Usage
-----------

[](#basic-usage)

Create 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.

```
$dateRange = new DateRange(
    new DateTimeImmutable('23rd June 18 14:00'),
    new DateTimeImmutable('2018-06-23T15:00')
);
echo $dateRange->format('H:i d M Y'); // 14:00 – 15:00 23 Jun 2018
```

If the formatted date would be the same start and end date, only a single date is displayed:

```
$dateRange = new DateRange(
    new DateTimeImmutable('23rd June 18 14:00'),
    new DateTimeImmutable('2018-06-23T15:00')
);
echo $dateRange->format('jS M Y'); // 23rd Jun 2018
```

Advanced Usage
--------------

[](#advanced-usage)

### Change Separator

[](#change-separator)

The default separator between the start and end date, is a space, en-dash, space: `' – '`

This can be changed via the `changeSeparator()` method:

```
$dateRange = new DateRange(
    new DateTimeImmutable('23rd June 18 14:00'),
    new DateTimeImmutable('2018-06-23T15:00')
);
$dateRange->changeSeparator(' to ');
echo 'From ', $dateRange->format('H:i d M Y'); // From 14:00 to 15:00 23 Jun 2018
```

### Change Removable Delimiters

[](#change-removable-delimiters)

The consolidation and removal of some time parts may leave delimiters from the format:

```
$dateRange = new DateRange(
    new DateTimeImmutable('23rd June 18'),
    new DateTimeImmutable('2018-06-24')
);
echo $dateRange->format('d·M·Y'); //  23·· – 24·Jun·2018
```

Be default, `/`, `-` and `.` are trimmed from the start date, but this can be amended with the `changeRemovableDelimiters()` method:

```
$dateRange = new DateRange(
    new DateTimeImmutable('23rd June 18'),
    new DateTimeImmutable('2018-06-24')
);
$dateRange->changeRemovableDelimiters('·');
echo $dateRange->format('d·M·Y'); //  23 – 24·Jun·2018
```

Known Issues
------------

[](#known-issues)

These are known issues which need addressing before this package can be considered stable:

- [Escaped characters are not handled correctly](https://github.com/GaryJones/daterange/issues/2)
- [Duplicate time parts are not handled correctly](https://github.com/GaryJones/daterange/issues/3)
- [Hours, minutes and seconds are not handled correctly](https://github.com/GaryJones/daterange/issues/4)

Contributing
------------

[](#contributing)

All feedback, bug reports and pull requests are welcome.

License
-------

[](#license)

Copyright (c) 2018 Gary Jones, Gamajo

This code is licensed under the [MIT License](LICENSE).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Total

2

Last Release

2897d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba7751eebec0f74a4963e9a062f49e58222b97872bf193d95f0505f3df321d09?d=identicon)[GaryJones](/maintainers/GaryJones)

---

Top Contributors

[![GaryJones](https://avatars.githubusercontent.com/u/88371?v=4)](https://github.com/GaryJones "GaryJones (5 commits)")

---

Tags

datedate-rangephp71

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/gamajo-daterange/health.svg)

```
[![Health](https://phpackages.com/badges/gamajo-daterange/health.svg)](https://phpackages.com/packages/gamajo-daterange)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
