jmf / twig-time
Twig模板中处理日期和时间的扩展。
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
安装与需求
使用Composer安装 Composer
composer require jmf/twig-time
如果需要使用国际化日期格式,则必须安装PHP的intl扩展。
在Twig模板中的使用
microtime() 函数
返回当前的毫秒/微秒级时间戳
{% set now = microtime() %}
intl_format() 过滤器
使用国际化格式化IntlCalendar / DateTime对象。
有关可用的格式化标记符,请参阅https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax。
{{ date|intl_format('cccc', 'fr_CA.UTF-8') }}