mdxdave / time-ago
显示时间间隔
1.1.0
2022-06-09 15:54 UTC
Requires
- craftcms/cms: ^4.0.0
- nesbot/carbon: ^2.0.0
This package is auto-updated.
Last update: 2024-09-09 21:03:26 UTC
README
在Craftcms3 Twig模板中显示给定时间戳的时间间隔。
要求
此插件需要Craft CMS 4.0.0或更高版本。
安装
要安装插件,请按照以下说明操作。
-
打开您的终端并转到您的Craft项目目录
cd /path/to/project
-
然后告诉Composer加载插件
composer require mdxdave/time-ago
-
在控制面板中,转到设置→插件,并为TimeAgo点击“安装”按钮。
使用TimeAgo
只需在您的Twig模板文件中使用以下代码即可
{{ entry.postDate.getTimestamp()|timeAgo }}
如果您想使用除英语以外的其他语言,请使用
{{ entry.postDate.getTimestamp()|timeAgo("de") }}
由 MDXDave 提供