jmf / twig-time
Twig extension for handling date and time in Twig templates.
1.0.0
2024-06-05 16:04 UTC
Requires
- php: >=8.3
- twig/twig: ^3.0
Requires (Dev)
- phing/phing: ^2.17
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^11.1
- rector/rector: ^1.0
- squizlabs/php_codesniffer: ^3.8
Suggests
- ext-intl: Required for localized date and time formatting.
README
Installation & Requirements
Install with Composer:
composer require jmf/twig-time
PHP intl extension is required if you need to use internationalized date formats.
Usage in Twig templates
microtime() function
Returns current microtime (timestamp with milli/microseconds)
{% set now = microtime() %}
intl_format() filter
Formats provided IntlCalendar / DateTime object with internationalization.
See https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax for available formatting tokens.
{{ date|intl_format('cccc', 'fr_CA.UTF-8') }}