I have a blog. Regularly I post some fun thing. I maintain the timestamps for response times. How do I display the time like the following?
-
2010-02-09 1 hour before, if the reply is just 1 hour old
-
2010-02-09 20 hour before, if the reply is just 20 hour old
-
2010-02-08 yesterday, if the reply is just 1 day old
-
2010-02-04 17:20, if the reply is a couple of days before
I am maintaining the timestamp in a database as a Unix time. For example my timestamp is 1265709142.
How can this be implemented with PHP?
There is a JavaScript library for that: http://tpgblog.com/cutetime/.
Just print your dates in a certain format and add the JavaScript library to your page. Done.