PHPackages                             salavert/time-ago-in-words - 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. [Templating &amp; Views](/categories/templating)
4. /
5. salavert/time-ago-in-words

AbandonedArchivedLibrary[Templating &amp; Views](/categories/templating)

salavert/time-ago-in-words
==========================

Time ago Twig extension where you can easily convert a datetime or timestamp to a distance of time in words.

v1.7.1(7y ago)90623.8k↓16.4%30[3 issues](https://github.com/salavert/time-ago-in-words/issues)1MITPHPPHP ^7.1

Since May 28Pushed 5y ago6 watchersCompare

[ Source](https://github.com/salavert/time-ago-in-words)[ Packagist](https://packagist.org/packages/salavert/time-ago-in-words)[ Docs](http://github.com/salavert/time-ago-in-words)[ RSS](/packages/salavert-time-ago-in-words/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (13)Used By (1)

Time ago in words Twig extension
================================

[](#time-ago-in-words-twig-extension)

![Packagist](https://camo.githubusercontent.com/0e4844d3a64cf9a6afaab1413635793df3bc0fd2fcab694038592e0d38199163/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616c61766572742f74696d652d61676f2d696e2d776f7264732e737667) [![Build Status](https://camo.githubusercontent.com/73d3fe1515e124f7a03574a255f57e27a89b73e4fbc09b8e089d804a010e67d4/68747470733a2f2f7472617669732d63692e6f72672f73616c61766572742f74696d652d61676f2d696e2d776f7264732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/salavert/time-ago-in-words)

This is a Twig extension for Symfony Framework where you can easily convert a datetime/timestamp to a distance of time in words.

By example

```
{{ user.lastLogin | time_ago_in_words }}
```

Outputs **3 days ago**

Installation for Symfony
========================

[](#installation-for-symfony)

1. Update your composer.json

    - #### Symfony 2/3 with Twig 1/2

        [](#symfony-23-with-twig-12)

        ```
        "require": {
            "salavert/time-ago-in-words": "1.*"
        }
        ```

        or use composer's require command: `composer require salavert/time-ago-in-words:1.*`
    - #### Symfony 4 with Twig 2/3

        [](#symfony-4-with-twig-23)

        ```
        "require": {
            "salavert/time-ago-in-words": "2.*"
        }
        ```

        or use composer's require command: `composer require salavert/time-ago-in-words:2.*`
2. Register an Extension as a Service

Now you must let the Service Container know about your newly created Twig Extension:

YAML:

```
# app/config/config.yml
services:
    salavert.twig.time_ago:
        class: Salavert\Twig\Extension\TimeAgoExtension
        arguments: ["@translator"]
        tags:
            - { name: twig.extension }
```

XML:

```
# or into your bundle src\Acme\AcmeBundle\Resources\config\services.xml

```

Usage
=====

[](#usage)

To display distance of time in words between a date and current date:

```
{{ message.created | time_ago_in_words }}

```

To display distance of time between two custom dates you should use

```
{{ message.created | distance_of_time_in_words(message.updated) }}

```

You also have two available options, for both time\_ago\_in\_words &amp; distance\_of\_time\_in\_words filters

- include\_seconds (boolean) if you need more detailed seconds approximations if time is less than a minute
- include\_months (boolean) if you want days to be approximated in months if time is greater than 31 days.

Thus, if you want to have the months approximation but not the seconds one, you should use:

```
{{ message.created | time_ago_in_words(false, true) }}

```

Translations
============

[](#translations)

Add the following translations to your

- `\app\Resources\translations\messages.locale.yml` or
- `\translations\messages.locale.yml`

This is a translation to spanish:

```
# Time ago in words - Twig Extension
less than %seconds seconds ago: hace menos de %seconds segundos
half a minute ago: hace medio minuto
less than a minute ago: hace menos de un minuto
1 minute ago: hace 1 minuto
%minutes minutes ago: hace %minutes minutos
about 1 hour ago: hace casi 1 hora
about %hours hours ago: hace %hours horas
1 day ago: hace 1 día
%days days ago: hace %days días
"{1} 1 month ago |]1,Inf[ %months months ago": "{1} hace un mes |]1,Inf[ hace %months meses"
"{1} 1 year ago |]1,Inf[ %years years ago":  "hace un año |]1,Inf[ Hace %years años"

```

In the same case, for future:

```
# Time ago in words - Twig Extension
in less than %seconds seconds: en menos de %seconds segundos
in half a minute: en medio minuto
in less than a minute: en menos de un minuto
in 1 minute: en 1 minuto
in %minutes minutes: en %minutes minutos
in about 1 hour: dentro de casi 1 hora
in about %hours hours: en %hours horas
in 1 day: en 1 día
in %days days: en %days días

```

Testing
=======

[](#testing)

To launch all tests first make sure dependecies are met with composer and run:

```
./vendor/phpunit/phpunit/phpunit

```

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 62% 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 ~194 days

Recently: every ~346 days

Total

12

Last Release

2599d ago

PHP version history (3 changes)v1.0PHP &gt;=5.3.0

v1.7PHP &gt;=5.5.0

v1.7.1PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/3597293aa4649719564dd4ed2a600edec825300b511d38f5453b1d0526d160b6?d=identicon)[Salavert](/maintainers/Salavert)

---

Top Contributors

[![salavert](https://avatars.githubusercontent.com/u/216846?v=4)](https://github.com/salavert "salavert (49 commits)")[![desarrolla2](https://avatars.githubusercontent.com/u/661529?v=4)](https://github.com/desarrolla2 "desarrolla2 (3 commits)")[![stevelacey](https://avatars.githubusercontent.com/u/289531?v=4)](https://github.com/stevelacey "stevelacey (3 commits)")[![nixilla](https://avatars.githubusercontent.com/u/608548?v=4)](https://github.com/nixilla "nixilla (3 commits)")[![aldor007](https://avatars.githubusercontent.com/u/2446168?v=4)](https://github.com/aldor007 "aldor007 (3 commits)")[![tomlebot](https://avatars.githubusercontent.com/u/748707?v=4)](https://github.com/tomlebot "tomlebot (3 commits)")[![robertobermejo](https://avatars.githubusercontent.com/u/221931?v=4)](https://github.com/robertobermejo "robertobermejo (2 commits)")[![slejnej](https://avatars.githubusercontent.com/u/7508599?v=4)](https://github.com/slejnej "slejnej (2 commits)")[![dantleech](https://avatars.githubusercontent.com/u/530801?v=4)](https://github.com/dantleech "dantleech (2 commits)")[![davidino](https://avatars.githubusercontent.com/u/265253?v=4)](https://github.com/davidino "davidino (2 commits)")[![micronax](https://avatars.githubusercontent.com/u/1337823?v=4)](https://github.com/micronax "micronax (2 commits)")[![vhpoet](https://avatars.githubusercontent.com/u/686185?v=4)](https://github.com/vhpoet "vhpoet (1 commits)")[![benjamindulau](https://avatars.githubusercontent.com/u/430689?v=4)](https://github.com/benjamindulau "benjamindulau (1 commits)")[![ChristianVermeulen](https://avatars.githubusercontent.com/u/1062751?v=4)](https://github.com/ChristianVermeulen "ChristianVermeulen (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![adam187](https://avatars.githubusercontent.com/u/156628?v=4)](https://github.com/adam187 "adam187 (1 commits)")

---

Tags

twigtimetime agodistance of timetime ago in words

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/salavert-time-ago-in-words/health.svg)

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

###  Alternatives

[twig/extra-bundle

A Symfony bundle for extra Twig extensions

91492.0M315](/packages/twig-extra-bundle)[twig/intl-extra

A Twig extension for Intl

36763.2M221](/packages/twig-intl-extra)[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[twig/string-extra

A Twig extension for Symfony String

22046.0M133](/packages/twig-string-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

22918.5M55](/packages/twig-cssinliner-extra)[symfony/ux-twig-component

Twig components for Symfony

21914.8M162](/packages/symfony-ux-twig-component)

PHPackages © 2026

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