In MySQL, you can use the functions DATEDIFF() and TIMEDIFF() .
SELECT DATEDIFF(CURDATE(), createdate) AS output_day, TIMEDIFF(CURDATE(), createdate) AS output_time FROM message_table
For output_day, it is already in the day block. But output_time requires additional manipulation to get the hourly portion of the time difference.
Hope this helps.
Osh mansor
source share