如何在没有秒的情况下格式化 MySQL TIMEDIFF? [英] How can I format a MySQL TIMEDIFF without seconds?

查看:44
本文介绍了如何在没有秒的情况下格式化 MySQL TIMEDIFF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行这个 SELECT 语句:

I'm running this SELECT statement:

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

并以 02:58:32 格式获取结果.最后一组数字 :32 是秒数.

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

如何省略秒?

推荐答案

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

查阅手册更多关于 TIME_FORMAT() 和允许的说明符表.

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

这篇关于如何在没有秒的情况下格式化 MySQL TIMEDIFF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆