PHPackages                             danharper/dti - 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. danharper/dti

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

danharper/dti
=============

Parse ISO 8601 date, duration and interval strings into DateTime objects

v1.0.0(10y ago)245.2k2[1 PRs](https://github.com/danharper/DTI/pulls)MITPHPPHP &gt;=5.3.0

Since Nov 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/danharper/DTI)[ Packagist](https://packagist.org/packages/danharper/dti)[ Docs](https://github.com/danharper/DTI)[ RSS](/packages/danharper-dti/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

DTI
===

[](#dti)

Parse ISO 8601 dates and intervals.

[![Build Status](https://camo.githubusercontent.com/b8b59d3cbb7f80a67bda06d1c74907d07e3d3f01f2e054da7e7f6ae955921faa/68747470733a2f2f7472617669732d63692e6f72672f64616e6861727065722f4454492e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/danharper/DTI)[![Total Downloads](https://camo.githubusercontent.com/7b552f69a07656998f68e8983096e0cfffd1024e0321964b8e7a486d62a969c5/68747470733a2f2f706f7365722e707567782e6f72672f64616e6861727065722f6474692f646f776e6c6f616473)](https://packagist.org/packages/danharper/dti)

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

[](#installation)

Install via Composer by adding the following line to the dependencies in your composer.json:

```
danharper/dti: "~1.0"

```

And run `composer install`/`composer update`

Usage
-----

[](#usage)

```
$dti = new danharper\DTI;
```

Passing a single ISO 8601 datetime string will provide you with an array containing that time, and the current time.

```
list($from, $to) = $dti->parse('2007-03-01T13:00:00Z');
```

Passing a single ISO 8601 duration string will substract that duration from the current time.

```
list($from, $to) = $dti->parse('PT2H30M');
// from is set to 2h30m before the current time
```

Optionally, provide `parse()` with the default time to use instead of the current time:

```
$dti->parse('PT2H30M', new DateTime('2001-01-01'));
```

Passing a ISO 8601 duration string consisting of two datetimes, will give you them:

```
$dti->parse('2007-03-01T13:00:00Z/2008-05-11T15:30:00Z');
```

A duration string consisting of a datetime and a duration will give the datetime provided, and the datetime with the duration added to it.

```
$dti->parse('2007-03-01T13:00:00Z/P1Y2M10DT2H30M');
```

And in reverse, will give you the datetime with the duration substracted, and the datetime:

```
$dti->parse('PT2H30M/2007-03-01T13:00:00Z');
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

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

Unknown

Total

1

Last Release

3841d ago

### Community

Maintainers

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

---

Top Contributors

[![danharper](https://avatars.githubusercontent.com/u/510740?v=4)](https://github.com/danharper "danharper (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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