Skip to content

Provides a simple twig filter for expressing time difference in words.

License

Notifications You must be signed in to change notification settings

sarokse/time-ago-bundle

 
 

Repository files navigation

TimeAgoBundle

Provides a simple twig filter for expressing time difference in words for Symfony. Uses a range of +-7 days, after that, the actual date is returned.

Install

Composer (Packagist):

composer require eschmar/time-ago-bundle dev-master

app/Appkernel.php:

new Eschmar\TimeAgoBundle\EschmarTimeAgoBundle(),

Usage

$now = new \DateTime();

$foo = new \DateTime();
$foo->modify('-3 minutes');

$bar = new \DateTime();
$bar->modify('-3 months');

$foobar = new \DateTime();
$foobar->modify('+4 hours');
{{ now|ago }}
{# just now #}

{{ foo|ago('r') }}
{# 3 minutes ago #}

{{ bar|ago('r') }}
{# actual date in 'r' format #}

{{ foobar|ago }}
{# in 4 hours #}

Change default format in config.yml:

eschmar_time_ago:
    format: 'Y-m-d H:i:s'

Translations available

  • Belarusian
  • Croatian
  • Dutch
  • English
  • French
  • German
  • Hindi
  • Hungarian
  • Indonesian
  • Italian
  • Polish
  • Portuguese (Brazil)
  • Romanian
  • Russian
  • Slovenian
  • Spanish
  • Swedish
  • Turkish
  • Ukranian
  • Vietnamese

License

MIT License

About

Provides a simple twig filter for expressing time difference in words.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%