jmf/twig-time

Twig模板中处理日期和时间的扩展。

1.0.0 2024-06-05 16:04 UTC

This package is auto-updated.

Last update: 2024-09-05 16:37:00 UTC


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') }}