rymanalu/twitter-time-ago

以类似Twitter的"时间前"格式显示日期。

v1.0.0 2016-12-21 15:33 UTC

This package is auto-updated.

Last update: 2024-09-09 15:33:36 UTC


README

Build Status

此包提供了解析日期到可读时间差的功能,例如Twitter

安装

composer require rymanalu/twitter-time-ago

用法

use Rymanalu\TwitterTimeAgo\TwitterTimeAgo;

$timeAgo = new TwitterTimeAgo; // or `new TwitterTimeAgo($timezone)`
echo $timeAgo->parse('2016-12-21 12:06:45');
// You can also just pass a date...
echo $timeAgo->parse('2016-12-12');

// Using static method...
echo TwitterTimeAgo::parse('2016-12-21 12:06:45');

// Using global helper...
echo twitter_time_ago($datetime);