teraone / twig-strftime-extension
use strftime function in twig
Installs: 51 890
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 5
Open Issues: 0
Requires
- twig/twig: 1.*|~2.4
Requires (Dev)
- phpunit/phpunit: 4.7
README
Use strftime in twig
{{ now|date_modify("+3 day")|strftime('%A') }} //-> Monday (if today is thursday at least :) ) {{ date()|strftime('%I:%M:%S %p') }} //-> Display the current time {{ '2017-12-01'|strftime('%d %B %Y') }} //-> Accept string filtering (compatible with strtotime)
Installation
composer require teraone/twig-strftime-extension
Add the extension to your twig environment
// set your locale setlocale(LC_ALL, 'de_DE'); $twig->addExtension(new Teraone\Twig\Extension\StrftimeExtension()); // optional: set Timezone $twig->getExtension('core')->setTimezone('Europe/Berlin');
For the full list of supported time formats have a look at the PHP strftime documentation