siniliote-twig/date-extra
最新稳定版本:v3.4.0
Composer 安装命令:
composer require siniliote-twig/date-extra
包简介
A Twig extension to transform time diff in human readable
关键字:
README 文档
README
The Date extension provides the time_diff filter.
time_diff
Use the time_diff filter to render the difference between a date and now.
{{ post.published_at|time_diff }}
The example above will output a string like 4 seconds ago or in 1 month,
depending on the filtered date.
Arguments
-
date: The date for calculate the difference from now. Can be a string or a DateTime instance. -
now: The date that should be used as now. Can be a string or a DateTime instance. Do not set this argument to use current date.
Translation
To get a translatable output, give a Symfony\Contracts\Translation\TranslatorInterface
as constructor argument. The returned string is formatted as diff.ago.XXX
or diff.in.XXX where XXX can be any valid unit: second, minute, hour, day, month, year.
统计信息
- 总下载量: 3.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-28