anders / twig-strftime-extension
use strftime function in twig
1.1.0
2017-09-13 07:46 UTC
Requires
- twig/twig: 1.*
Requires (Dev)
- phpunit/phpunit: 4.7
This package is auto-updated.
Last update: 2024-10-29 05:40:26 UTC
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
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