PHPackages                             timeset/timeset - 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. timeset/timeset

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

timeset/timeset
===============

Package for time intervals manipulation

07[2 issues](https://github.com/SN1054/Timeset/issues)PHP

Since Dec 23Pushed 4y ago1 watchersCompare

[ Source](https://github.com/SN1054/Timeset)[ Packagist](https://packagist.org/packages/timeset/timeset)[ RSS](/packages/timeset-timeset/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Timeset
=======

[](#timeset)

Timeset is a package that helps dealing with time intervals in PHP. Time intervals are considered as sets on [real line](https://en.wikipedia.org/wiki/Real_line). Aside from a few auxilary operations, only 4 basic operations are supported: OR, AND, XOR, NOT. [Others](https://en.wikipedia.org/wiki/Set_(mathematics)#Basic_operations) can be derived from those.

Features
--------

[](#features)

- Flyweight
- No dependencies
- Easy to use

Example
-------

[](#example)

Imagine you have two employees, and they have their schedules and their appointments. You need to calculate when they both are free.

```
$firstEmployee = new stdClass();
$secondEmployee = new stdClass();

$firstEmployee->schedule = Set::create([
    ['2020-10-10 10:00:00', '2020-10-10 20:00:00'],
    ['2020-10-11 10:00:00', '2020-10-11 20:00:00'],
    // other intervals
]);

$firstEmployee->appointments = Set::create([
    ['2020-10-10 11:00:00', '2020-10-10 15:00:00'],
    ['2020-10-10 16:00:00', '2020-10-10 19:00:00'],
    // other intervals
]);

$secondEmployee->schedule = Set::create([
    ['2020-10-10 10:00:00', '2020-10-10 20:00:00'],
    ['2020-10-12 10:00:00', '2020-10-12 20:00:00'],
    // other intervals
]);

$secondEmployee->appointments = Set::create([
    ['2020-10-10 12:00:00', '2020-10-10 15:00:00'],
    ['2020-10-10 16:00:00', '2020-10-10 19:00:00'],
    // other intervals
]);

$intervalsOnWhichFirstEmployeeIsFree = $firstEmployee->schedule->and(
    $firstEmployee->appointments->not()
);

$intervalsOnWhichSecondEmployeeIsFree = $secondEmployee->schedule->and(
    $secondEmployee->appointments->not()
);

$intervalsOnWhichBothEmployeesAreFree = $intervalsOnWhichFirstEmployeeIsFree->and(
    $intervalsOnWhichSecondEmployeeIsFree
);

```

Now we can filter, for example, those intervals shorter than 3 hours:

```
$neededIntervals = array_filter(
    $intervalsOnWhichBothEmployeesAreFree->sets(),
    fn($interval) => $interval->length()->h >= 3
);

```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/673afb85e7504b1f441a6e9afa1feb9e7d768f9b6929e8ebdfaa3257c6e01355?d=identicon)[SN1054](/maintainers/SN1054)

---

Top Contributors

[![SN1054](https://avatars.githubusercontent.com/u/62817037?v=4)](https://github.com/SN1054 "SN1054 (33 commits)")

### Embed Badge

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

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

###  Alternatives

[pecl/mailparse

Email message manipulation

361.4k](/packages/pecl-mailparse)[zakurdaev/yii2-editorjs-widget

Use editor.js in form. Module for Yii2

101.5k1](/packages/zakurdaev-yii2-editorjs-widget)

PHPackages © 2026

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