Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I format a MySQL TIMEDIFF without seconds?

Tags:

time

mysql

I'm running this SELECT statement:

TIMEDIFF(NOW(), posts.date_modified) as time_ago

And getting results in the format 02:58:32. The last set of digits, :32, are the number of seconds.

How can I omit the seconds?

like image 724
cwd Avatar asked Dec 31 '11 04:12

cwd


1 Answers

SELECT TIME_FORMAT(TIMEDIFF(NOW(), posts.date_modified), '%H:%i') AS time_ago

Consult the manual for more on TIME_FORMAT() and a table of allowed specifiers.

like image 71
Erwin Brandstetter Avatar answered Sep 25 '22 17:09

Erwin Brandstetter