PHPackages                             magicspacepanda/time-duration - 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. magicspacepanda/time-duration

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

magicspacepanda/time-duration
=============================

Convert durations into human-readable timestamps.

1.0.0(6y ago)48.2k↓33.3%MITPHPPHP ^7.2 || ^8.0

Since Nov 21Pushed 6y ago1 watchersCompare

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

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

Time Duration
=============

[](#time-duration)

[![Latest Stable Version](https://camo.githubusercontent.com/42dec478260b15afb8eda1e744571a6e2b7b6fd89e689eeebc138782226c22c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61676963737061636570616e64612f74696d652d6475726174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/magicspacepanda/time-duration)[![Build Status](https://camo.githubusercontent.com/42e60bd983f23d089132f2d47edaad966dd8e9ab2fb5bb71dff2ff938390ed31/68747470733a2f2f7472617669732d63692e636f6d2f6c65656d636435362f74696d652d6475726174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/leemcd56/time-duration)

This library was created to make parsing time entered into a task manager as easy as it is on popular apps like [Harvest](https://getharvest.com/) or [Tempo for JIRA](https://marketplace.atlassian.com/vendors/6558/tempo-for-jira).

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

[](#requirements)

- PHP 7.2 or higher
- Composer (if used as library)

Install
-------

[](#install)

### With Composer

[](#with-composer)

`composer require magicspacepanda/time-duration`

How to Use
----------

[](#how-to-use)

```
use MagicSpacePanda\TimeDuration;

// Handles durations as a float (1 hour and 45 minutes)
$floatTime = TimeDuration::createFromNumeric(1.75);
printf("Time spend on project is %s", $floatTime);

// Handles durations as an integer (3 hours)
$intTime = TimeDuration::createFromNumeric(1);
printf("Time spend on project is %s", $intTime);

// Handles durations as a string (5 hours and 25 minutes)
$strTime = TimeDuration::createFromString('5h 25m');
printf("Time spend on project is %s", $strTime);

// Convert output to DateTime instance
$floatTime->toDateTime();

// Convert output to custom format
$intTime->toFormat('H:i');

// Convert output to machine-friendly milliseconds
$strTime->toMilliseconds();
```

Contributing
------------

[](#contributing)

If you would like to contribute to this library, please create a pull request for me to review. Should your code be accepted I will add your name below.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

2370d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f403bd440b13ae66db52fed7f05fdaf9d6581288d7d8ab40f53d76279252a3b?d=identicon)[MagicSpacePanda](/maintainers/MagicSpacePanda)

---

Tags

composer-libraryphptimetimeintervalduration

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/magicspacepanda-time-duration/health.svg)

```
[![Health](https://phpackages.com/badges/magicspacepanda-time-duration/health.svg)](https://phpackages.com/packages/magicspacepanda-time-duration)
```

###  Alternatives

[brick/date-time

Date and time library

3623.3M61](/packages/brick-date-time)[knplabs/knp-time-bundle

Making your dates and durations look sensible and descriptive

6308.9M39](/packages/knplabs-knp-time-bundle)[league/period

Time range API for PHP

7335.4M21](/packages/league-period)[symfony/clock

Decouples applications from the system clock

431168.9M205](/packages/symfony-clock)[khill/php-duration

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

1611.7M20](/packages/khill-php-duration)[sybio/gif-frame-extractor

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

179417.2k8](/packages/sybio-gif-frame-extractor)

PHPackages © 2026

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