PHPackages                             swisnl/date-range - 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. swisnl/date-range

ActiveLibrary

swisnl/date-range
=================

A PHP package for manipulating date ranges.

1.1.0(4mo ago)0136MITPHPPHP ^8.2CI passing

Since Aug 15Pushed 6d agoCompare

[ Source](https://github.com/swisnl/date-range)[ Packagist](https://packagist.org/packages/swisnl/date-range)[ Docs](https://github.com/swisnl/date-range)[ GitHub Sponsors](https://github.com/swisnl)[ RSS](/packages/swisnl-date-range/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (7)Versions (7)Used By (0)

Date Range
==========

[](#date-range)

[![Latest Version on Packagist](https://camo.githubusercontent.com/525abb585c8917baba3f3d1af23c671d884ca5d280c8d13597d4f61b79bfdbfc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737769736e6c2f646174652d72616e67652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/swisnl/date-range)[![Software License](https://camo.githubusercontent.com/cbe927e857a92d608128a52eec4a36a3d2720299ffe875cffa69ef191a0dfe91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f737769736e6c2f646174652d72616e67652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Buy us a tree](https://camo.githubusercontent.com/cec0a9b35a1c3235bdbe0d13ea8fbd866a23e30280ad6ca27078c1fd4ac1b709/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d6c69676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://plant.treeware.earth/swisnl/date-range)[![Made by SWIS](https://camo.githubusercontent.com/ef6bdd6ab8d4f47bceb74dcf558b0915c6b419cbba320096324af0518e43091d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2546302539462539412538302d6d6164652532306279253230535749532d2532333037333741392e7376673f7374796c653d666c61742d737175617265)](https://www.swis.nl)

This PHP package provides classes for immutable objects to represent date ranges and methods to manipulate them.

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

[](#installation)

You can install the package via composer:

```
composer require swisnl/date-range
```

Usage
-----

[](#usage)

`Swis\DateRange\DateRange` is the main class to represent a date range. It is an immutable object that has a start and end date (both optional to support open ended ranges), and provides methods to manipulate the range. Because manipulating date ranges can easily lead to multiple separate date ranges, the package also provides a `Swis\DateRange\DateRangeSet` class to represent a collection of date ranges. This class also provides methods to manipulate set of date ranges. Both classes are immutable, so any manipulation will return a new instance of the class.

```
use Swis\DateRange\DateRange;

$range = DateRange::make('2023-01-01', '2023-01-31');
$range->inRange('2023-01-15'); // true
$range->inRange('2023-02-01'); // false

$range2 = DateRange::make('2023-01-15', '2023-01-20');
$range->overlaps($range2); // true
$range->intersect($range2)->toArray(); // ['2023-01-15', '2023-01-20']
$range->subtract($range2)->toArray(); // [['2023-01-01', '2023-01-14'], ['2023-01-21', '2023-01-31']]

$set = $range->subtract($range2);
$set->addDateRange(DateRange::make('2023-01-10', null)); // [['2023-01-01', null]]
```

For all the available methods, please refer to the PHPDoc documentation in the source code.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](https://github.com/swisnl/date-range/blob/main/CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/swisnl/date-range/blob/main/CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](https://github.com/swisnl/date-range/blob/main/CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Rolf van de Krol](https://github.com/rolfvandekrol)
- [All Contributors](https://github.com/swisnl/date-range/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/swisnl/date-range/blob/main/LICENSE.md) for more information.

This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/swisnl/date-range) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

SWIS ❤️ Open Source
-------------------

[](#swis-️-open-source)

[SWIS](https://www.swis.nl) is a web agency from Leiden, the Netherlands. We love working with open source software.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance90

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.6% 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 ~97 days

Total

2

Last Release

120d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8734305?v=4)[SWIS](/maintainers/swisnl)[@swisnl](https://github.com/swisnl)

![](https://www.gravatar.com/avatar/692b75a6dde1f076e7248f8f35cda5d6b68d993046ac0a08158d49b72b71ba38?d=identicon)[rolfvandekrol](/maintainers/rolfvandekrol)

---

Top Contributors

[![rolfvandekrol](https://avatars.githubusercontent.com/u/434397?v=4)](https://github.com/rolfvandekrol "rolfvandekrol (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![JaZo](https://avatars.githubusercontent.com/u/3475007?v=4)](https://github.com/JaZo "JaZo (1 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/swisnl-date-range/health.svg)

```
[![Health](https://phpackages.com/badges/swisnl-date-range/health.svg)](https://phpackages.com/packages/swisnl-date-range)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k48.3M311](/packages/tymon-jwt-auth)[illuminate/support

The Illuminate Support package.

583105.3M30.0k](/packages/illuminate-support)[directorytree/ldaprecord

A fully-featured LDAP ORM.

5732.8M8](/packages/directorytree-ldaprecord)[illuminate/console

The Illuminate Console package.

12943.4M4.3k](/packages/illuminate-console)[illuminate/process

The Illuminate Process package.

44658.7k46](/packages/illuminate-process)[trebol/entrust

This package provides a flexible way to add role-based permissions to Laravel and is a fork from Zizaco/entrust

1571.9k](/packages/trebol-entrust)

PHPackages © 2026

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