hexmedia/time-formatter-bundle

Symfony2 扩展,用于以秒为单位展示时间

安装: 283

依赖者: 1

建议者: 0

安全: 0

星标: 2

关注者: 3

分支: 1

公开问题: 1

类型:symfony-bundle

v1.0.1 2013-11-20 15:40 UTC

This package is not auto-updated.

Last update: 2024-09-24 05:53:18 UTC


README

Build Status Build Status Latest Stable Version Latest Unstable Version

这是一个为 Symfony2 框架提供的 Bundle,您可以使用它轻松地将日期时间戳转换为时间的文字距离。

例如

{{ var.data|time_formatter }}

输出

day ago

Symfony2 安装

  1. 更新您的 composer.json
{
	"require": {
		"Hexmedia/TimeFormatterBundle": "dev-master"
	}
}

或使用 composer 的 require 命令

composer require Hexmedia/TimeFormatterBundle:dev-master
  1. 更新 AppKernel
	public function registerBundles() {
		$bundles = array(
			...
			new Hexmedia\TimeFormatterBundle\HexmediaTimeFormatterBundle(),
			...
			);
		return $bundles;
	}

使用方法

要显示日期与当前日期之间的时间文字距离

{{ var.data|time_formatter }}

要显示两个自定义日期之间的时间距离,您应该使用

{{ var.data|time_formatter(message.updated) }}