PHPackages                             bendahrooge/relative-time - 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. bendahrooge/relative-time

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

bendahrooge/relative-time
=========================

Relative Time Calculator for PHP in 100 lines

118PHP

Since Dec 15Pushed 10y ago1 watchersCompare

[ Source](https://github.com/bendahrooge/relative-time)[ Packagist](https://packagist.org/packages/bendahrooge/relative-time)[ RSS](/packages/bendahrooge-relative-time/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

RelativeTime
============

[](#relativetime)

Relative Time Calculator for PHP in 100 lines Relative time has been increasing popular amoung social media applications and micro-blog posts where the exact date content was posted isn't important or can be confusing to the end-user. The Library compares two Unix timestamps and outputs the elapsed time in minutes, hours, days, months or years.

Note: Relative time is different from elapsed time. Elapsed time has a focus on accuracy whereas relative time tries to be as human-readable as possible-even if it uses excessive rounding to do so. Relative time is not supposed to be accurate, therefore it should only be utilized in specific use cases.

Install via composer
--------------------

[](#install-via-composer)

Run this command in this command in your terminal to quickly install the package using composer.

```
composer require bendahrooge/relative-time

```

If you don't know what composer is (its pretty awesum) [check out the documentation to install it.](https://getcomposer.org/doc/00-intro.md)

Getting Relative Time
---------------------

[](#getting-relative-time)

If you're using composer, the class will already be included by default on every script. You can start an instance of the class like this:

```
$RelativeTime = new bendahrooge\RelativeTime;

```

The Library has 3 public functions avaible for use. All functions only support Unix time at the moment, if you wanna fix that and make a pull request that's cool.

```
$RelativeTime = new bendahrooge\RelativeTime;

$lastyear = $RelativeTime->since(1420000000); //This is Unix time for Wed Dec 31 2014 04:26:40
$afewdays = $RelativeTime->between(array(1449964800, 1450137600)); //About 1 day passing
$cantwait = $RelativeTime->until(1513296000); //Some time in the future

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2881758?v=4)[Benjamin Dahrooge](/maintainers/bendahrooge)[@bendahrooge](https://github.com/bendahrooge)

---

Top Contributors

[![bendahrooge](https://avatars.githubusercontent.com/u/2881758?v=4)](https://github.com/bendahrooge "bendahrooge (19 commits)")

### Embed Badge

![Health badge](/badges/bendahrooge-relative-time/health.svg)

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

###  Alternatives

[yii2mod/yii2-star-rating

Star rating widget based on jQuery Raty https://github.com/wbotelhos/raty

1915.5k](/packages/yii2mod-yii2-star-rating)[inspiredminds/contao-fieldset-duplication

Contao extension to allow the duplication of form fieldsets in the front end by the user for additional input fields.

138.5k1](/packages/inspiredminds-contao-fieldset-duplication)

PHPackages © 2026

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