PHPackages                             rm/dateinterval - 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. rm/dateinterval

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

rm/dateinterval
===============

DateInterval extension

v0.1.1(8y ago)22.0kMITPHPPHP &gt;=7.0

Since Oct 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/romanmatyus/DateInterval)[ Packagist](https://packagist.org/packages/rm/dateinterval)[ Docs](https://github.com/romanmatyus/DateInterval)[ RSS](/packages/rm-dateinterval/feed)WikiDiscussions master Synced 4d ago

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

RM\\DateInterval
================

[](#rmdateinterval)

[![Build Status](https://camo.githubusercontent.com/c529278f8ff9d7058c9bfea37cd995a0c9fca19fef67963f61b0d0eaa99f440b/68747470733a2f2f7472617669732d63692e6f72672f726f6d616e6d61747975732f44617465496e74657276616c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/romanmatyus/DateInterval)[![Code Quality](https://camo.githubusercontent.com/d90e7dbcb58319c50debfb471dccbe59711eafc2abf893411d79a3be0f6d5c84/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f6d616e6d61747975732f44617465496e74657276616c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/romanmatyus/DateInterval/)[![Code Coverage](https://camo.githubusercontent.com/d3bcad5f01e8837eabe95137ae6ad11a30d77ebbb88a19faf1c4fbc4f49c5a30/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f6d616e6d61747975732f44617465496e74657276616c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/romanmatyus/DateInterval/)[![Latest Stable Version](https://camo.githubusercontent.com/1d81d2262a1e6526c2458bf8290c65a56aac9e2db4d5c129b5d0cebf3c057eb1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f726f6d616e6d61747975732f44617465496e74657276616c2e737667)](https://packagist.org/packages/rm/dateinterval)[![Latest Unstable Version](https://camo.githubusercontent.com/12373223c8269a9ddf6c3354421f66b7597ad92511ede3a0ee99ff6b548c7e3e/68747470733a2f2f706f7365722e707567782e6f72672f726d2f64617465696e74657276616c2f762f756e737461626c65)](https://packagist.org/packages/rm/dateinterval)[![License](https://camo.githubusercontent.com/1aa44c90c3b000c4aba5b7f657d6663fc38aa3e77fbc179aaa725bd585b4fa6a/68747470733a2f2f706f7365722e707567782e6f72672f726d2f64617465696e74657276616c2f6c6963656e7365)](https://packagist.org/packages/rm/dateinterval)

Simple library for manipulating with date intervals in PHP.

Requirements
------------

[](#requirements)

- PHP 7.0

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

[](#installation)

```
$ composer require rm/dateinterval

```

Features
--------

[](#features)

### Extends creation possibility

[](#extends-creation-possibility)

```
namespace RM\DateInterval;

new DateInterval; // 0 seconds
new DateInterval('PT0S'); // 0 seconds
new DateInterval(new \DateInterval('PT0S')); // 0 seconds
new DateInterval('-P1D'); // - 1 day
new DateInterval('+2 minutes');
new DateInterval(10); // 10 seconds
new DateInterval(-1000); // -1000 seconds
new DateInterval(5.5); // 6 seconds
```

### Adding/Subtraction

[](#addingsubtraction)

Allowing summarize multiple intervals into one.

```
$interval = new \RM\DateInterval;
foreach ([
	'PT10S', // 0:10
	'PT13M14S', // 13:24
	'PT3M3S', // 16:27
	'PT4M58S', // 21:25
] as $data) {
	$interval->add($data);
}
echo $interval->format('%i:%s'); // '21:25'
```

### Convert to seconds

[](#convert-to-seconds)

> Usable for comparing.

```
(new \RM\DateInterval('+1 day'))->toSeconds(); // int(86400)
```

### Generate string

[](#generate-string)

Generating standardized `string`, for storing interval to database.

```
$now = new DateTime;
$next = clone $now;
$next->modify('+1 day') // 1 day
	->modify('+14 hours') // 1 day 14 hours
	->modify('-3 minutes') // 1 day 13 hours 57 mins
	->modify('13 seconds'); // 1 day 13 hours 57 mins 13 seconds
$interval = new \RM\DateInterval($now->diff($next));
echo (string) $interval; // P1DT13H57M13S

$interval = new \RM\DateInterval($string);
echo $interval->format('%dd %hh %im %ss'); // 1d 13h 57m 13s
```

Alternatively it's possible use only static method `RM\DateInterval::parse(DateInterval $interval)`.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

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

Total

2

Last Release

3136d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1110294?v=4)[Roman Mátyus](/maintainers/romanmatyus)[@romanmatyus](https://github.com/romanmatyus)

---

Top Contributors

[![romanmatyus](https://avatars.githubusercontent.com/u/1110294?v=4)](https://github.com/romanmatyus "romanmatyus (22 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[ctidigital/magento2-configurator

Keep magento persistently configured using files

174317.4k](/packages/ctidigital-magento2-configurator)[comcast/php-legal-licenses

A utility to generate a Licenses file containing the full license text for every dependency in your project for legal purposes.

821.1M9](/packages/comcast-php-legal-licenses)[xfra35/f3-cron

Job scheduling for the PHP Fat-Free Framework

73107.5k](/packages/xfra35-f3-cron)[hyperf/nacos

Nacos SDK

22487.9k10](/packages/hyperf-nacos)[bagusindrayana/laravel-coordinate

get nearby location from eloquent laravel

3019.7k](/packages/bagusindrayana-laravel-coordinate)

PHPackages © 2026

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