计算两个日期之间的时差,并提出答案如“2天3小时前” [英] Calculate time difference between two dates, and present the answer like "2 days 3 hours ago"

查看:120
本文介绍了计算两个日期之间的时差,并提出答案如“2天3小时前”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何用php编写的类/函数可以公开获取时间戳,并从天数,月,年等返回到此为止的时间?基本上,我想要同样的功能,生成自己发布的时间与本站点上的每个条目(以及digg和其他站点的负载)。

Are there any classes/functions written in php publicly available that will take a timestamp, and return the time passed since then in number of days, months, years etc? Basically i want the same function that generates the time-since-posted presented together with each entry on this site (and on digg and loads of other sites).

推荐答案

这是一个wordpress插件,但你可以提取相关的PHP代码没有问题:模糊日期时间

This is written as a wordpress plugin but you can extract the relevant PHP code no problem: Fuzzy date-time

这篇关于计算两个日期之间的时差,并提出答案如“2天3小时前”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆