How To Present A Past Time In Hours, Minutes And Seconds
Posted by Mary
19 Dec, 2011
If you want show an article was posted "n hours n minutes and n seconds ago", you can use the TIMEDIFF(NOW(), pastTime) function as shown in the following tutorial exercise:SELECT TIMEDIFF(NOW(), '2006-07-01 04:09:49') FROM DUAL; 06:42:58SELECT TIME_FORMAT(TIMEDIFF(NOW(), '2006-06-30 04:09:49'), '%H hours, %i minutes and %s seconds ago.') FROM DUAL; 30 hours, 45 minutes and 22 seconds ago.
If you want show an article was posted "n hours n minutes and n seconds ago", you can use the TIMEDIFF(NOW(), pastTime) function as shown in the following tutorial exercise:SELECT TIMEDIFF(NOW(), '2006-07-01 04:09:49') FROM DUAL; 06:42:58SELECT TIME_FORMAT(TIMEDIFF(NOW(), '2006-06-30 04:09:49'), '%H hours, %i minutes and %s seconds ago.') FROM DUAL; 30 hours, 45 minutes and 22 seconds ago.
Comments Received:
Please give your suggestions and feedback: