PHPackages                             joanfabregat/iso8601-to-seconds - 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. joanfabregat/iso8601-to-seconds

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

joanfabregat/iso8601-to-seconds
===============================

Converts ISO 8601 duration to seconds

v1.0(2y ago)064MITPHPPHP &gt;=8.2

Since Apr 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/joanfabregat/iso8601-to-seconds)[ Packagist](https://packagist.org/packages/joanfabregat/iso8601-to-seconds)[ Docs](https://github.com/joanfabregat/iso8601-to-seconds)[ RSS](/packages/joanfabregat-iso8601-to-seconds/feed)WikiDiscussions main Synced 1mo ago

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

ISO 8601 to seconds
===================

[](#iso-8601-to-seconds)

[![Latest Stable Version](https://camo.githubusercontent.com/56ef804f6cb52813963bce4b75530312b6736a3db3a9353bc619e62b04f8f377/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616e66616272656761742f69736f383630312d746f2d7365636f6e64732f76)](//packagist.org/packages/joanfabregat/iso8601-to-seconds)[![Total Downloads](https://camo.githubusercontent.com/ce026e221efcd0ae3f9269cf40ca1feadeaff4ae9b8695c5e244c60127a01f60/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616e66616272656761742f69736f383630312d746f2d7365636f6e64732f646f776e6c6f616473)](//packagist.org/packages/joanfabregat/iso8601-to-seconds)[![Latest Unstable Version](https://camo.githubusercontent.com/50f1acf0855ac332f37bb3641377e9f3b98103269ac9878af3e39ff9cbac106c/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616e66616272656761742f69736f383630312d746f2d7365636f6e64732f762f756e737461626c65)](//packagist.org/packages/joanfabregat/iso8601-to-seconds)[![License](https://camo.githubusercontent.com/994298e8096dc30afefb695b598da754994df9b34137592792ba77cf62b941c0/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616e66616272656761742f69736f383630312d746f2d7365636f6e64732f6c6963656e7365)](//packagist.org/packages/joanfabregat/iso8601-to-seconds)

A simple package to convert ISO 8601 duration to seconds

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

[](#installation)

The package is [available on Packagist](https://packagist.org/packages/joanfabregat/iso8601-to-seconds). The recommended way to install the library is through [Composer](http://getcomposer.org):

```
composer require joanfabregat/iso8601-to-seconds
```

Usage
-----

[](#usage)

```
use JoanFabregat\Iso8601ToSeconds\Iso8601ToSeconds;

$seconds = Iso8601ToSeconds::convert('PT1H');
echo $token; // will echo 3600

$interval = new DateInterval('PT1H');
$seconds = Iso8601ToSeconds::convert($interval);
echo $token; // will echo 3600

$interval = DateInterval::createFromDateString('1 hour');
$seconds = Iso8601ToSeconds::convert($interval);
echo $token; // will echo 3600

// will throw an \InvalidArgumentException exception
$token = Iso8601ToSeconds::convert('a random string');
```

License
-------

[](#license)

The library is published under the MIT license (see [`LICENSE`](LICENSE) file).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

749d ago

### Community

Maintainers

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

---

Top Contributors

[![joanfabregat](https://avatars.githubusercontent.com/u/4227907?v=4)](https://github.com/joanfabregat "joanfabregat (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/joanfabregat-iso8601-to-seconds/health.svg)

```
[![Health](https://phpackages.com/badges/joanfabregat-iso8601-to-seconds/health.svg)](https://phpackages.com/packages/joanfabregat-iso8601-to-seconds)
```

PHPackages © 2026

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