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

v2.0(2mo ago)064MITPHPPHP &gt;=8.2CI passing

Since Apr 30Pushed 2mo 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 2d ago

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

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

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

[![Latest Stable Version](https://camo.githubusercontent.com/56ef804f6cb52813963bce4b75530312b6736a3db3a9353bc619e62b04f8f377/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616e66616272656761742f69736f383630312d746f2d7365636f6e64732f76)](https://packagist.org/packages/joanfabregat/iso8601-to-seconds)[![Total Downloads](https://camo.githubusercontent.com/ce026e221efcd0ae3f9269cf40ca1feadeaff4ae9b8695c5e244c60127a01f60/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616e66616272656761742f69736f383630312d746f2d7365636f6e64732f646f776e6c6f616473)](https://packagist.org/packages/joanfabregat/iso8601-to-seconds)[![License](https://camo.githubusercontent.com/994298e8096dc30afefb695b598da754994df9b34137592792ba77cf62b941c0/68747470733a2f2f706f7365722e707567782e6f72672f6a6f616e66616272656761742f69736f383630312d746f2d7365636f6e64732f6c6963656e7365)](https://packagist.org/packages/joanfabregat/iso8601-to-seconds)[![CI](https://github.com/joanfabregat/iso8601-to-seconds/actions/workflows/ci.yml/badge.svg)](https://github.com/joanfabregat/iso8601-to-seconds/actions/workflows/ci.yml)

A simple PHP library to convert [ISO 8601 durations](https://en.wikipedia.org/wiki/ISO_8601#Durations) to seconds.

Accepts both ISO 8601 duration strings (e.g. `PT1H30M`) and `DateInterval` objects.

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

[](#requirements)

- PHP &gt;= 8.2

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

[](#installation)

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

Usage
-----

[](#usage)

```
use JoanFabregat\Iso8601ToSeconds\Iso8601ToSeconds;

// From an ISO 8601 string
$seconds = Iso8601ToSeconds::convert('PT1H');
echo $seconds; // 3600

// From a DateInterval object
$interval = new DateInterval('PT1H');
$seconds = Iso8601ToSeconds::convert($interval);
echo $seconds; // 3600

// Combined durations
$seconds = Iso8601ToSeconds::convert('P1DT2H30M15S');
echo $seconds; // 95415

// Invalid input throws \InvalidArgumentException
Iso8601ToSeconds::convert('not a duration'); // throws InvalidArgumentException
```

License
-------

[](#license)

This library is published under the MIT license (see [LICENSE](LICENSE)).

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance84

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Total

2

Last Release

80d ago

Major Versions

v1.0 → v2.02026-04-15

### 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 (4 commits)")

---

Tags

timeintervaldurationsecondsiso8601

###  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)
```

###  Alternatives

[brick/date-time

Date and time library

3663.8M109](/packages/brick-date-time)[knplabs/knp-time-bundle

Making your dates and durations look sensible and descriptive

6339.5M56](/packages/knplabs-knp-time-bundle)[league/period

Time range API for PHP

7335.8M24](/packages/league-period)[khill/php-duration

Converts between colon formatted time, human-readable time and seconds

1611.8M21](/packages/khill-php-duration)[sybio/gif-frame-extractor

PHP class that separates all the frames (and their duration) of an animated GIF

180437.0k9](/packages/sybio-gif-frame-extractor)[alroniks/dtms

Classes for manipulate dates and intervals with microseconds precision

187.5k](/packages/alroniks-dtms)

PHPackages © 2026

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