jmf / twig-time
Twig extension for handling date and time in Twig templates.
Installs: 106
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jmf/twig-time
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') }}