PHPackages                             fyre/period - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. fyre/period

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fyre/period
===========

A Date Period library.

v4.0.3(6mo ago)0261MITPHP

Since May 28Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyrePeriod)[ Packagist](https://packagist.org/packages/fyre/period)[ RSS](/packages/fyre-period/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (5)Versions (23)Used By (1)

FyrePeriod
==========

[](#fyreperiod)

**FyrePeriod** is a free, open-source date period library for *PHP*.

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

[](#table-of-contents)

- [Installation](#installation)
- [Periods](#periods)
- [Period Collections](#period-collections)

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

[](#installation)

**Using Composer**

```
composer require fyre/period

```

Periods
-------

[](#periods)

```
use Fyre\Period\Period;
```

- `$start` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) or string representing the start date.
- `$end` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) or string representing the end date.
- `$granularity` is a string representing the granularity, and can be one of either "*year*", "*month*", "*day*", "*hour*", "*minute*" or "*second*", and will default to "*day*".
- `$excludeBoundaries` is a string representing the excluded boundaries, and can be one of either "*none*", "*start*", "*end*" or "*both*", and will default to "*none*".

```
$period = new Period($start, $end, $granularity, $excludeBoundaries);
```

The *Period* is an implementation of an *Iterator* and can be used in a foreach loop.

```
foreach ($period AS $date) { }
```

**Contains**

Determine whether this period contains another *Period*.

- `$other` is the *Period* to compare against.

```
$contains = $period->contains($other);
```

**Diff Symmetric**

Get the symmetric difference between the periods.

- `$other` is the *Period* to compare against.

```
$diffSymmetric = $period->diffSymmetric($other);
```

This method will return a new [*PeriodCollection*](#period-collections).

**End**

Get the end date.

```
$end = $period->end();
```

This method will return a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).

**End Equals**

Determine whether this period ends on a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$endEquals = $period->endEquals($date);
```

**Ends After**

Determine whether this period ends after a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$endsAfter = $period->endsAfter($date);
```

**Ends After Or Equals**

Determine whether this period ends on or after a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$endsAfterOrEquals = $period->endsAfterOrEquals($date);
```

**Ends Before**

Determine whether this period ends before a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$endsBefore = $period->endsBefore($date);
```

**Ends Before Or Equals**

Determine whether this period ends on or before a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$endsBeforeOrEquals = $period->endsBeforeOrEquals($date);
```

**Equals**

Determine whether this period equals another Period.

- `$other` is the *Period* to compare against.

```
$equals = $period->equals($other);
```

**Gap**

Get the gap between the periods.

- `$other` is the *Period* to compare against.

```
$gap = $period->gap($other);
```

This method will return a new *Period*, or *null* if there's no gap.

**Granularity**

Get the granularity.

```
$granularity = $period->granularity();
```

**Included End**

Get the included end date.

```
$includedEnd = $period->includedEnd();
```

This method will return a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).

**Included Start**

Get the included start date.

```
$includedStart = $period->includedStart();
```

This method will return a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).

**Includes End**

Determine whether the Period includes the end date.

```
$includesEnd = $period->includesEnd();
```

**Includes**

Determine whether this period includes a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$includes = $period->includes($date);
```

**Includes Start**

Determine whether the Period includes the start date.

```
$includesStart = $period->includesStart();
```

**Length**

Get the length of the period.

```
$length = $period->length();
```

**Overlap**

Get the overlap of the periods.

- `$other` is the *Period* to compare against.

```
$overlap = $period->overlap($other);
```

This method will return a new *Period*, or *null* if there's no overlap.

**Overlap All**

Get the overlap of all the periods.

```
$overlapAll = $period->overlapAll(...$others);
```

This method will return a new *Period*, or *null* if there's no overlap.

**Overlap Any**

Get the overlaps of any of the periods.

```
$overlapAny = $period->overlapAny(...$others);
```

This method will return a new [*PeriodCollection*](#period-collections).

**Overlaps With**

Determine whether this period overlaps with another Period.

- `$other` is the *Period* to compare against.

```
$overlapsWith = $period->overlapsWith($other);
```

**Renew**

Create a new period with the same length after this period.

```
$renewed = $period->renew();
```

This method will return a new *Period*.

**Start**

Get the start date.

```
$start = $period->start();
```

This method will return a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).

**Start Equals**

Determine whether this period starts on a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$startEquals = $period->startEquals($date);
```

**Starts After**

Determine whether this period starts after a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$startsAfter = $period->startsAfter($date);
```

**Starts After Or Equals**

Determine whether this period starts on or after a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$startsAfterOrEquals = $period->startsAfterOrEquals($date);
```

**Starts Before**

Determine whether this period starts before a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$startsBefore = $period->startsBefore($date);
```

**Starts Before Or Equals**

Determine whether this period starts on or before a given date.

- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.

```
$startsBeforeOrEquals = $period->startsBeforeOrEquals($date);
```

**Subtract**

Get the inverse overlap of the periods.

- `$other` is the *Period* to compare against.

```
$subtract = $period->subtract($other);
```

This method will return a new [*PeriodCollection*](#period-collections).

**Subtract All**

Get the inverse overlap of all periods.

```
$subtractAll = $period->subtractAll(...$others);
```

This method will return a new [*PeriodCollection*](#period-collections).

**Touches**

Determine whether this period touches another Period.

- `$other` is the *Period* to compare against.

```
$touches = $period->touches($other);
```

Period Collections
------------------

[](#period-collections)

```
use Fyre\Period\PeriodCollection;
```

All arguments supplied will be used as periods for the collection.

```
$periodCollection = new PeriodCollection(...$periods);
```

The *PeriodCollection* is an implementation of an *Iterator* and can be used in a foreach loop.

```
foreach ($periodCollection AS $period) { }
```

**Add**

Add periods to the collection.

All arguments supplied will be used as periods to add to the collection.

```
$added = $periodCollection->add(...$periods);
```

This method will return a new *PeriodCollection*.

**Boundaries**

Get the boundaries of the collection.

```
$boundaries = $periodCollection->boundaries();
```

This method will return a new [*Period*](#periods), or *null* if the collection is empty.

**Gaps**

Get the the gaps between the periods in the collection.

```
$gaps = $periodCollection->gaps();
```

This method will return a new *PeriodCollection*.

**Intersect**

Intersect a period with every period in the collection.

- `$period` is the [*Period*](#periods) to compare against.

```
$intersect = $periodCollection->intersect($period);
```

This method will return a new *PeriodCollection*.

**Overlap All**

Get the overlap of all the collections.

All arguments supplied will be used as collections to compare against.

```
$overlapAll = $periodCollection->overlapAll(...$others);
```

This method will return a new *PeriodCollection*.

**Sort**

Sort the periods.

```
$sorted = $periodCollection->sort();
```

This method will return a new *PeriodCollection*.

**Subtract**

Get the inverse overlap of the collections.

- `$others` is the *PeriodCollection* to compare against.

```
$subtract = $periodCollection->subtract($others);
```

This method will return a new *PeriodCollection*.

**Unique**

Filter the periods to remove duplicates.

```
$unique = $periodCollection->unique();
```

This method will return a new *PeriodCollection*.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance67

Regular maintenance activity

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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 ~59 days

Recently: every ~24 days

Total

22

Last Release

196d ago

Major Versions

v1.0 → v2.02023-07-16

v2.0.4 → v3.02024-06-02

v3.1.7 → v4.02025-10-20

### Community

Maintainers

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

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (25 commits)")

---

Tags

dateperiodphp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/fyre-period/health.svg)

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

PHPackages © 2026

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