teraone/twig-strftime-extension

在twig中使用strftime函数

1.2.2 2023-12-19 11:49 UTC

This package is auto-updated.

Last update: 2024-09-19 14:31:49 UTC


README

在twig中使用strftime

{{ 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)

安装

composer require teraone/twig-strftime-extension

将扩展添加到您的twig环境中

// set your locale
setlocale(LC_ALL, 'de_DE');
$twig->addExtension(new Teraone\Twig\Extension\StrftimeExtension());

// optional: set Timezone
$twig->getExtension('core')->setTimezone('Europe/Berlin');

有关支持的完整时间格式列表,请参阅PHP strftime文档