PHP code example of little-sumo-labs / time-ago-twig-filter

1. Go to this page and download the library: Download little-sumo-labs/time-ago-twig-filter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

little-sumo-labs / time-ago-twig-filter example snippets


use littlesumolabs\timeago\relativeTimerFilter as relativeTimer;

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

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

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')))
]);

{{ date|relativetimer }} <br />
{{ timer|relativetimer }} <br />
{{ timer2|relativetimer }}