PHPackages                             little-sumo-labs/time-ago-twig-filter - 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. little-sumo-labs/time-ago-twig-filter

ActiveLibrary

little-sumo-labs/time-ago-twig-filter
=====================================

Extensions for Twig, giving a date in a more understandable format

1.0.0(8y ago)014MITPHPPHP &gt;= 7.1.0

Since Apr 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Little-sumo-labs/time-ago-twig-filter)[ Packagist](https://packagist.org/packages/little-sumo-labs/time-ago-twig-filter)[ RSS](/packages/little-sumo-labs-time-ago-twig-filter/feed)WikiDiscussions master Synced 5d ago

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

Get Relative Time in Twig
=========================

[](#get-relative-time-in-twig)

[![Build Status](https://camo.githubusercontent.com/5527afa2c787d173ceaab0353f3fcc4f7bed3718f8d6b36e79137bb124af7caf/68747470733a2f2f7472617669732d63692e6f72672f4c6974746c652d73756d6f2d6c6162732f74696d652d61676f2d747769672d66696c7465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Little-sumo-labs/time-ago-twig-filter)[![Coverage Status](https://camo.githubusercontent.com/377dbd5ce256d7d87d69026ce86d4228250639e39d736c6542ed33aba445a580/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4c6974746c652d73756d6f2d6c6162732f74696d652d61676f2d747769672d66696c7465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Little-sumo-labs/time-ago-twig-filter?branch=master)

Extensions for Twig, giving a date in a more understandable format (e.g. '1 hour ago', 'yesterday', 'tomorrow', 'in 2 weeks')

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

[](#installation)

```
composer require little-sumo-labs/time-ago-twig-filter
```

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

[](#how-to-use-it)

### Import the filter namespace

[](#import-the-filter-namespace)

```
use littlesumolabs\timeago\relativeTimerFilter as relativeTimer;
```

### initializing the filter for Twig

[](#initializing-the-filter-for-twig)

```
$twig->addExtension(new relativeTimer());
```

Or

```
$twig->addExtension(new relativeTimer('America/Chicago'));
```

### Creation of 'date' variable, which is injected into the Twig view

[](#creation-of-date-variable-which-is-injected-into-the-twig-view)

```
echo $twig->render('index.twig', [
    'date'		=> date("d M Y H:i:s"),
    'timer'     => date('d M Y H:i:s', strtotime('-1 hour', strtotime('now'))),
    'timer2'    => date("d M Y H:i:s", strtotime('+1 day', strtotime('now')))
]);
```

### Using the filter in the Twig view

[](#using-the-filter-in-the-twig-view)

```
{{ date|relativetimer }}
{{ timer|relativetimer }}
{{ timer2|relativetimer }}
```

### Example of use

[](#example-of-use)

[page d'exemple](index.php)

future developments
-------------------

[](#future-developments)

- Adding translations for different languages (French, English, Spanish, etc ...)
- ...

Useful links
------------

[](#useful-links)

### Articles divers

[](#articles-divers)

- [Timer relatif](https://www.grafikart.fr/tutoriels/javascript/timer-relatif-800)
- [Créer une date relative en PHP](https://www.dewep.net/realisations/creer-une-date-relative-en-php)
- [Formats supportés de temps et de dates](http://www.php.net/manual/fr/datetime.formats.php)
- [Liste des Fuseaux Horaires Supportés en PHP](http://php.net/manual/fr/timezones.php)

### Documentation Twig

[](#documentation-twig)

- [Twig for Developers](https://twig.symfony.com/doc/2.x/api.html)
- [Extending Twig](https://twig.symfony.com/doc/2.x/advanced.html)
- [The i18n Extension](http://twig-extensions.readthedocs.io/en/latest/i18n.html)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

2964d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab180cce65c8cb24b87152cbcfa837f550d8f435912a19ab69b13c45632e5580?d=identicon)[Guillaume-RICHARD](/maintainers/Guillaume-RICHARD)

---

Top Contributors

[![wseng](https://avatars.githubusercontent.com/u/6572161?v=4)](https://github.com/wseng "wseng (3 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/little-sumo-labs-time-ago-twig-filter/health.svg)

```
[![Health](https://phpackages.com/badges/little-sumo-labs-time-ago-twig-filter/health.svg)](https://phpackages.com/packages/little-sumo-labs-time-ago-twig-filter)
```

###  Alternatives

[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[abydahana/aksara

Aksara is a CodeIgniter based CRUD Toolkit you can use to build complex applications become shorter, secure and more reliable just in a few lines of code. Serving both CMS or Framework, produce both HEADLESS (RESTful API) or TRADITIONAL (Browser Based), just by writing single controller. Yet it's reusable, scalable and ready to use!

1101.2k](/packages/abydahana-aksara)

PHPackages © 2026

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