开发者

How might I format relative dates the way Stack Overflow does "member since" and "last seen"? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How do I calculate relative time?

I want to know how to display these data as seen on stackoverflow.com profile page. I have the timestamp of users registered 开发者_C百科date and last visit date. But I need to display using stackoverflow.com format.

For example:

Member since: 9 months

Last seen: just now

Is there any script to convert these dates and display in such format?


This is a duplicate of this question which is a duplicate of this question which has some great code samples including PHP.

In addition to all this, if are you using jQuery you can do this client-side with something like the timeago plugin. It has the advantage of updating the text as time passes so if you load a page and it says "posted 5 minutes ago" and look again 5 minutes later, it says "posted 10 minutes ago"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜