PHPackages                             mkusher/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. mkusher/time-ago-in-words

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

mkusher/time-ago-in-words
=========================

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

v1.1(12y ago)22751MITPHPPHP &gt;=5.3.0

Since Feb 18Pushed 10y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

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

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

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

By example

```
{{ user.lastLogin|ago }}

```

Output examples

```
half a minute ago
3 minutes ago
about 1 hour ago
Today at 04:14 AM
Yersterday at 17:36 PM
18 Feb at 3:26 PM
22 Dec 2013

```

Installation for Symfony2
=========================

[](#installation-for-symfony2)

1. Update your composer.json

```
{
	"require": {
		"mkusher/time-ago-in-words": "dev-master"
	}
}

```

or use composer's require command:

```
composer require mkusher/time-ago-in-words:1.*

```

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:
	mkusher.twig.time_ago:
		class: Mkusher\Twig\Extension\TimeAgoExtension
		arguments: [@translator, @sonata.intl.templating.helper.datetime]
		tags:
		- { name: twig.extension }

```

XML:

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

```

And update your AppKernel.php:

```
