Skip to content

Instantly share code, notes, and snippets.

@andrewjennings
Created November 14, 2012 15:14
Show Gist options
  • Save andrewjennings/4072693 to your computer and use it in GitHub Desktop.
Save andrewjennings/4072693 to your computer and use it in GitHub Desktop.
Twig Filter
<?php
namespace Afj\CourseBundle\Twig;
use Afj\CourseBundle\Util\DateUtil;
class CourseExtension extends \Twig_Extension
{
public function getName()
{
return 'Course';
}
public function getFilters()
{
return array(
'ago' => new \Twig_Filter_Method($this, 'ago'),
//'ago' => new \Twig_Filter_Method('Afj\CourseBundle\Util\DateUtil', 'ago'),
);
}
public function ago(\DateTime $date)
{
return DateUtil::ago($date);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment