【问题标题】:How can I format a MySQL TIMEDIFF without seconds?如何在没有秒的情况下格式化 MySQL TIMEDIFF?
【发布时间】:2011-12-31 04:46:38
【问题描述】:

我正在运行这个SELECT 声明:

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

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

如何省略秒数?

【问题讨论】:

    标签: mysql time


    【解决方案1】:
    SELECT TIME_FORMAT(TIMEDIFF(NOW(), posts.date_modified), '%H:%i') AS time_ago
    

    请参阅manual for more on TIME_FORMAT() 和允许的说明符表。

    【讨论】:

      猜你喜欢
      • 2010-10-08
      • 1970-01-01
      • 1970-01-01
      • 2011-02-23
      • 2023-01-11
      • 2021-04-11
      • 1970-01-01
      • 2016-01-10
      • 1970-01-01
      相关资源
      最近更新 更多