I’ve created a stored procedure in MySQL Server 5.1.
How can I convert a timestamp to a string that represents the days, hours, and minutes difference between that timestamp and now?
For example, if the timestamp is 5 hours and 3 minutes ago I’ll get ‘5 hours 3 minutes ago’.
If you want more luxury you can do something like:
Plus a few extra spaces here and there.
If one of the timestamps is
nullnaturally the result will also be null, you’ll have to make sure it is not, or useifnull(`timestamp`,now())to fix that.See: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_timediff