<?php

namespace AppBundle\Twig;

class AppExtension extends \Twig_Extension
{
    public function getFilters()
    {
        return array(
            new \Twig_SimpleFilter('datetime', array($this, 'datetime'))
        );
    }

    public function datetime($d, $format = "%B")
    {
        $d = new \DateTime($d);
        if ($d instanceof \DateTime) {
            $d = $d->getTimestamp();
        }

        return strftime($format, $d);
    }
}