PHPackages                             bretterer/iso\_duration\_converter - 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. bretterer/iso\_duration\_converter

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

bretterer/iso\_duration\_converter
==================================

Easily convert ISO\_8601 Duration time format to seconds and convert seconds to ISO-8601 Duration

v0.1.0(10y ago)271.9M—7.9%15MITPHP

Since Feb 11Pushed 10y ago1 watchersCompare

[ Source](https://github.com/bretterer/iso_duration_converter)[ Packagist](https://packagist.org/packages/bretterer/iso_duration_converter)[ RSS](/packages/bretterer-iso-duration-converter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (5)

PHP ISO8601 Duration Converter
==============================

[](#php-iso8601-duration-converter)

Easily converts ISO 8601 Durations to Seconds and Seconds to ISO 8601 Durations

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

[](#installation)

```
composer require bretterer/iso_duration_converter
```

Usage
-----

[](#usage)

```
$converter = new \Bretterer\IsoDurationConverter\DurationParser();
$converter->parse('PT8S'); // Returns 8
$converter->parse('PT5M'); // Returns 300
$converter->parse('PT20H'); // Returns 72000
$converter->parse('PT6M4S'); // Returns 364

$converter->compose(8); // Returns PT8S
$converter->compose(300); // Returns PT5M
$converter->compose(7200); // Returns PT20H
$converter->compose(364); //Returns PT6M4S

$converter->parse('P5W'); // Returns 3024000
// To Returns Weeks, The second argument should be true
$converter->compose(3024000, true); // Returns P5W
$converter->compose(3024000); // Returns P35D

$converter->parse('Hello World'); // Throws 'Invalid Argument Exception' with Message 'Invalid Duration'
$converter->parse('P10Y10M10D'); // Throws 'Invalid Argument Exception' with Message 'Ambiguous Duration'
```

Years and Months
----------------

[](#years-and-months)

If years are passed into the `parse` method, an `invalid argument exception` will be thrown.

If you are wanting to convert seconds into months, pass true as the second argument in the `compose` method

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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

3749d ago

### Community

Maintainers

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

---

Top Contributors

[![adriancrepaz](https://avatars.githubusercontent.com/u/306156?v=4)](https://github.com/adriancrepaz "adriancrepaz (1 commits)")[![bretterer](https://avatars.githubusercontent.com/u/1906920?v=4)](https://github.com/bretterer "bretterer (1 commits)")

### Embed Badge

![Health badge](/badges/bretterer-iso-duration-converter/health.svg)

```
[![Health](https://phpackages.com/badges/bretterer-iso-duration-converter/health.svg)](https://phpackages.com/packages/bretterer-iso-duration-converter)
```

###  Alternatives

[classiebit/addchat-laravel

Live chat widget for Laravel that also includes multi-user chat, group permissions, customer support chat &amp; more.

13912.0k](/packages/classiebit-addchat-laravel)

PHPackages © 2026

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