PHPackages                             phplegends/timespan - 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. phplegends/timespan

Abandoned → [wallacemaxters/timespan](/?search=wallacemaxters%2Ftimespan)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

phplegends/timespan
===================

A timespan library

1.0.0(4y ago)12.9kMITPHP

Since Dec 22Pushed 4y ago2 watchersCompare

[ Source](https://github.com/phplegends/timespan)[ Packagist](https://packagist.org/packages/phplegends/timespan)[ RSS](/packages/phplegends-timespan/feed)WikiDiscussions master Synced 1mo ago

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

PHPLegends\\Timespan Library
============================

[](#phplegendstimespan-library)

This is a library to work only with time durations in PHP.

With it you can work with the time very simply:

```
use PHPLegends\Timespan\Timespan;

$time = new Timespan(0, 0, 10);

echo $time->format(); // '00:00:10'

$time->addSeconds(30);

echo $time->format(); // '00:00:40'

$time->addSeconds(-50);

echo $time->format(); // '-00:00:10'

$time->addMinutes(2);

echo $time->format('%i minutes %s seconds');  // '1 minutes 50 seconds'
```

An example of time duration:

```
$time = Timespan::createFromFormat(
    Timespan::DEFAULT_FORMAT,
    '26:00:00'
);

echo $time->format(); // '26:00:00'
```

For create time duration from DateTime Diff, you can use `Timespan::createFromDateDiff`.

```
$timespan = Timespan::createFromDateDiff(
    new DateTime('2021-01-01 23:00:00'),
    new DateTime('2021-01-03 02:00:00')
);

echo $timespan->format(); // '27:00:00'
```

Available time format characters
--------------------------------

[](#available-time-format-characters)

  Character Description   %h The hour value.   %i The minute value. From `0`to `59`.   %I The total minutes value.   %s The second value. From `0`to `59`.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

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

Unknown

Total

1

Last Release

1604d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/983cda3e30a5a58d250f3bef7360267e0185b46e891f2f08e6683d0af9a9ddc7?d=identicon)[wallacemaxters](/maintainers/wallacemaxters)

---

Top Contributors

[![wallacemaxters](https://avatars.githubusercontent.com/u/5245865?v=4)](https://github.com/wallacemaxters "wallacemaxters (20 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/phplegends-timespan/health.svg)

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

###  Alternatives

[samgranger/module-store-code-body-class

The Store Code Body Class module for Magento2 adds the website &amp; store code to the body class.

3260.3k](/packages/samgranger-module-store-code-body-class)

PHPackages © 2026

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