Home >> FAQs/Tutorials >> MySQL Tutorials
MySQL Tutorial - Presenting a Past Time in Hours, Minutes and Seconds
(Continued from previous topic...)
How To Present a Past Time in Hours, Minutes and Seconds?
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
SELECT TIMEDIFF(NOW(), '2006-07-01 04:09:49') FROM DUAL;
SELECT 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.
(Continued on next topic...)
- What Are Date and Time Data Types?
- How To Write Date and Time Literals?
- How To Enter Microseconds in SQL Statements?
- How To Convert Dates to Character Strings?
- How To Convert Character Strings to Dates?
- What Are Date and Time Intervals?
- How To Increment Dates by 1?
- How To Decrement Dates by 1?
- How To Calculate the Difference between Two Dates?
- How To Calculate the Difference between Two Time Values?
- How To Present a Past Time in Hours, Minutes and Seconds?
- How To Extract a Unit Value from a Date and Time?
- What Are Date and Time Functions?
- What Is TIMESTAMP Data Type?
- How Many Ways to Get the Current Time?