PHPackages                             inthere/datetime-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. inthere/datetime-range

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

inthere/datetime-range
======================

Provides capabilities to parse or build tstzranges for Postgres databases

2.1.0(5y ago)01.9k1MITPHPPHP ^7.1|^8.0

Since Aug 25Pushed 5y ago3 watchersCompare

[ Source](https://github.com/InThere/datetime-range)[ Packagist](https://packagist.org/packages/inthere/datetime-range)[ RSS](/packages/inthere-datetime-range/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

DateTimeRange
=============

[](#datetimerange)

The Postgres database supports [ranges](https://www.postgresql.org/docs/current/static/rangetypes.html). This package provides capabilities to parse or build tstzranges for Postgres databases. This package attempts to fully support all the features of the tstzrange type. We made an exception for null values, which are interpreted as "infinity".

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

[](#installation)

You can install the package via composer:

`composer require inthere/datetime-range`

Usage
-----

[](#usage)

```
$parser = new Parser(
    '["2015-08-14 16:07:28.956968+02","2018-08-14 16:07:28.956968+02"]',
     new DateTimeZone('UTC')
);
$dateTimeRange = $parser->parse();
```

This returns a `DateTimeRange` object, which can provide the lower and upper range:

```
$lowerRange = $dateTimeRange->getLowerRange();
$upperRange = $dateTimeRange->getUpperRange();
```

A `Range` object will be returned which contains the date, the boundary and which knows if the range is "infinity":

```
$lowerRange->isInfinity();
// returns a boolean

$lowerRange->getDateTime();
// returns a datetime object or null if infinity

$lowerRange->getBoundary();
// returns a boundary object
```

The `Boundary` object determines if the range is inclusive \[\] or exclusive () and if the range is lower or upper:

```
$boundary = $lowerRange->getBoundary();

$boundary->isLower();
// returns a boolean (true = lower, false = upper)

$boundary->isInclusive();
// returns a boolean (true = inclusive, false = exclusive)
```

Tests
-----

[](#tests)

`$ vendor/bin/phpunit`

Contributors
------------

[](#contributors)

Contributions are welcome. We accept contributions via pull requests on Github.

License
-------

[](#license)

The MIT License (MIT). Please see the [License File](LICENSE) for more information.

About InThere
-------------

[](#about-inthere)

InThere - "The training Through Gaming Company" - speeds up training your team and change processes by providing a micro-training concept based on serious games.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~210 days

Recently: every ~315 days

Total

7

Last Release

1968d ago

Major Versions

1.1.1 → 2.0.02019-08-15

PHP version history (2 changes)2.0.0PHP ^7.1

2.1.0PHP ^7.1|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/171642141?v=4)[InThere](/maintainers/InThere)[@INTHERE](https://github.com/INTHERE)

---

Top Contributors

[![WesleyKlop](https://avatars.githubusercontent.com/u/12008100?v=4)](https://github.com/WesleyKlop "WesleyKlop (2 commits)")[![dvdheiden](https://avatars.githubusercontent.com/u/90568118?v=4)](https://github.com/dvdheiden "dvdheiden (1 commits)")

---

Tags

phppostgreststzrange

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/inthere-datetime-range/health.svg)

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

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M41](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46143.1k6](/packages/jstewmc-rtf)[moonshine/layouts-field

Field for repeating groups of fields for MoonShine

107.9k](/packages/moonshine-layouts-field)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

112.9k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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