如何显示几秒前/分钟前/使用unix时间戳?

时间:2010-05-12 19:33:54

标签: php unix time

我需要unix时间戳 - 我的时间戳。然后在twitter上显示之间的时间。

3 个答案:

答案 0 :(得分:3)

不确定您需要哪种语言,但如果它最终会出现在网页中,您可以尝试timeago

答案 1 :(得分:3)

如果你有差异叫做diff:

$seconds = intval($diff) % 60;
$minutes = intval($diff/60) % 60;
$hours = intval($diff/3600) % 24;
$days = intval($diff/(3600*24));

这是你想要的吗?

答案 2 :(得分:0)

使用示例:

echo time_elapsed_string('@1367367755');
echo time_elapsed_string('@1367367755', true);

输出:

4 months ago
4 months, 2 weeks, 3 days, 1 hour, 49 minutes, 15 seconds ago

<强> Link to the function.

相关问题