commentar / 时间前
此包计算从特定的 `DateTime` 对象以来经过的时间,并以人类可读的格式显示。
v0.0.3
2013-09-08 19:14 UTC
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2024-09-06 09:27:52 UTC
README
为 Commentar 项目提供日期渲染器。此包计算从特定的 DateTime
对象以来经过的时间,并以人类可读的格式显示。例如 5分钟前
。
支持以下时间步长
- 秒
- 分钟
- 小时
- 天
- 周
- 月
- 年
首次安装 Commentar 系统时,默认安装。
安装
如果您正在运行标准的 Commentar 安装,您无需安装任何内容(它是系统的默认时间戳格式化程序)。
将格式化程序添加到项目的 composer.json
文件中
"require": {
"commentar/time-ago": "0.0.*",
}
在模板中使用它
<?php echo $this->renderView('TimeAgo', ['timestamp' => $comment['updated']]); ?>