Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teraone/twig-strftime-extension
Use strftime in twig
https://github.com/teraone/twig-strftime-extension
Last synced: 21 days ago
JSON representation
Use strftime in twig
- Host: GitHub
- URL: https://github.com/teraone/twig-strftime-extension
- Owner: teraone
- License: mit
- Created: 2015-07-09T14:57:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-19T13:03:31.000Z (6 months ago)
- Last Synced: 2024-05-14T04:44:25.806Z (about 1 month ago)
- Language: PHP
- Size: 19.5 KB
- Stars: 1
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-twig - Strftime - use strftime function in twig (Twig / Extensions)
- awesome-twig - Strftime - use strftime function in twig (Twig / Extensions)
README
# Twig strftime Filter
Use strftime in twig```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
```bash
composer require teraone/twig-strftime-extension
```Add the extension to your twig environment
```php
// 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