How to get datetime in words like “today”, “yesterday” or “25 minutes ago”? [duplicate]

烈酒焚心 提交于 2019-12-12 00:33:41

问题


Possible Duplicate:
How do I calculate relative time?
How to display “12 minutes ago” etc in a PHP webpage?

I have date formats like this:

2011-09-10 12:00:00
2011-09-12 11:02:05
2011-09-12

I want to create a function that will get a date and will output something like this ?

5 minutes ago
2 hours ago
today
yesterday

and show date if date is far away.

Is there any related function in php or any free already written library.

Thanks

来源:https://stackoverflow.com/questions/7392566/how-to-get-datetime-in-words-like-today-yesterday-or-25-minutes-ago

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!