I have stored a date in database as “15-10-2012“,while showing in the front end when the date is not older than one day.I need to show 2 min age , 5 hours ago etc.
how can i achieve this?
thanks in advance.
Input
15-10-2012
Output
"2 days ago"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See this article http://www.ozzu.com/programming-forum/mysql-selecting-timestamp-from-database-now-minute-t82112.html
And take a look at MYSQL’s INTERVAL
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
I think this will help you:
WHERE UNIX_TIMESTAMP(your_date) > (NOW() - INTERVAL 5 MINUTE)