PHPackages                             technodelight/php-time-ago - 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. technodelight/php-time-ago

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

technodelight/php-time-ago
==========================

Simple module which displays the date in a "time ago" format

1.2.2(1y ago)21.7kMITPHPPHP &gt;=5.4

Since Jun 25Pushed 1y agoCompare

[ Source](https://github.com/technodelight/php-time-ago)[ Packagist](https://packagist.org/packages/technodelight/php-time-ago)[ Docs](https://github.com/technodelight/php-time-ago)[ RSS](/packages/technodelight-php-time-ago/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (1)Versions (17)Used By (0)

What is TimeAgo?
================

[](#what-is-timeago)

TimeAgo is a tiny and dynamic library, which has the ability of displaying `DateTime` objects as a neat "ago" string.

```
  0  29 secs                                                             # => less than a minute
  30 secs  1 min, 29 secs                                                # => 1 minute
  1 min, 30 secs  44 mins, 29 secs                                       # => [2..44] minutes
  44 mins, 30 secs  89 mins, 29 secs                                     # => about 1 hour
  89 mins, 29 secs  23 hrs, 59 mins, 29 secs                             # => about [2..24] hours
  23 hrs, 59 mins, 29 secs  47 hrs, 59 mins, 29 secs                     # => 1 day
  47 hrs, 59 mins, 29 secs  29 days, 23 hrs, 59 mins, 29 secs            # => [2..29] days
  29 days, 23 hrs, 59 mins, 30 secs  59 days, 23 hrs, 59 mins, 29 secs   # => about 1 month
  59 days, 23 hrs, 59 mins, 30 secs  1 yr minus 1 sec                    # => [2..12] months
  1 yr  2 yrs minus 1 secs                                               # => about 1 year
  2 yrs  max time or date                                                # => over [2..X] years

```

Above example is using the default `RuleSet`, but you can define your own when you want:

```
$ruleSet = new Technodelight\TimeAgo\Translation\RuleSet;
$ruleSet->add(
  new Rule(
    'aboutOneDay', // rule name, which would be used as a translation key
    '23hour' // timespan, as a limit, without spaces between numerics and time. Check DefaultRuleSet for examples
  ),
  new Formatter(
    'day', // duration type, according to durations in \Technodelight\TimeAgo\Translation\SecondsDurationMap
    'floor' // strategy (function) to use for calculating the amount. In this example "days" are calculated with floor()
  )
);
$timeAgo = new Technodelight\TimeAgo(
    new DateTime('-1 hour'),
    new Technodelight\TimeAgo\Translator(
        new Technodelight\TimeAgo\Translation( // this only needs an array as an input
            [
                'aboutOneDay' => 'About one day'
            ]
        ),
        $ruleSet
    )
);

$timeAgo->inWords(); // => About one day

```

The example below shows how customisable is TimeAgo:

```
// with all dependencies injected:
$translationLoader = new Technodelight\TimeAgo\TranslationLoader; // can load built-in translations
$timeAgo = new Technodelight\TimeAgo(
    new DateTime('-1 hour'), // static datetime
    new Technodelight\TimeAgo\Translator(
        $translationLoader->load('hu') // use a fixed translation
    )
);

// or simply:
$timeAgo = Technodelight\TimeAgo::withTranslation(new \DateTime('-1 hour'), 'hu');

$timeAgo->inWords(); // => körülbelül 1 órája

```

In the above example you can pass any of the translations supplied with this repository. All credits goes to Jimmi Westerberg and to the contributors of his repository.

By default, the `TimeAgo` uses the current system language as a guide to determine the required translation file, and it defaults to english if this information was not successfully resolved. Of course, you can pass your own translation when required:

```
$timeAgo = new Technodelight\TimeAgo(
    new DateTime('-1 hour'),
    new Technodelight\TimeAgo\Translator(
        ['aboutOneHour' => 'Happened an hour ago! Arrr! Arrr!']
    )
);

$timeAgo->inWords(); // => Happened an hour ago! Arrr! Arrr!

```

Credits
=======

[](#credits)

This repository is inspired by the original work made by Jimmi Westerberg (), his repository could be found at  .

License
=======

[](#license)

The MIT License (MIT)

Copyright (c) 2018 Zsolt Gál

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Original License
================

[](#original-license)

The MIT License

Copyright © 2014 Jimmi Westerberg ()

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 73.8% 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 ~247 days

Recently: every ~801 days

Total

16

Last Release

688d ago

Major Versions

0.4.7 → 1.0.02015-10-27

PHP version history (2 changes)0.3.0PHP &gt;=4

1.0.0PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/77a47c8d32780e9a7a8aadd58e7b7f835913edb7fdffd7b009a7b2be6a63283e?d=identicon)[technodelight](/maintainers/technodelight)

---

Top Contributors

[![jimmiw](https://avatars.githubusercontent.com/u/45835?v=4)](https://github.com/jimmiw "jimmiw (31 commits)")[![killmenot](https://avatars.githubusercontent.com/u/119337?v=4)](https://github.com/killmenot "killmenot (4 commits)")[![technodelight](https://avatars.githubusercontent.com/u/1817035?v=4)](https://github.com/technodelight "technodelight (4 commits)")[![cmfcmf](https://avatars.githubusercontent.com/u/2145092?v=4)](https://github.com/cmfcmf "cmfcmf (1 commits)")[![derekmd](https://avatars.githubusercontent.com/u/823566?v=4)](https://github.com/derekmd "derekmd (1 commits)")[![rimager](https://avatars.githubusercontent.com/u/7401367?v=4)](https://github.com/rimager "rimager (1 commits)")

---

Tags

time agodistance of timetime ago in words

### Embed Badge

![Health badge](/badges/technodelight-php-time-ago/health.svg)

```
[![Health](https://phpackages.com/badges/technodelight-php-time-ago/health.svg)](https://phpackages.com/packages/technodelight-php-time-ago)
```

###  Alternatives

[jimmiw/php-time-ago

Simple module, that displays the date in a "time ago" format

2661.2M18](/packages/jimmiw-php-time-ago)[mpratt/relativetime

A library that calculates the time difference between two dates and returns the result in words (Example: 5 minutes ago or 5 Minutes left). The library supports other languages aswell like Spanish and German.

31120.2k2](/packages/mpratt-relativetime)[phplot/phplot

PHP graph library for dynamic scientific, business, and stock-market charts and graphs.

1259.7k1](/packages/phplot-phplot)[hiromi2424/collectionable

Collectionable plugin for CakePHP

172.3k](/packages/hiromi2424-collectionable)

PHPackages © 2026

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