mysql时间相减获取秒数

ans

time_to_sec(timediff(endTime, startTime))
timestampdiff(second, startTime, endTime)
unix_timestamp(endTime) -unix_timestamp(startTime)

tips

mysql的时间相减是做了一个隐式转换操作,直接把年月日时分秒拼起来:
2022年3月27日 19:15:56 转换为 20220327191556
所以必须使用上述函数进行相减

posted @ 2022-03-27 19:17  cee_nil  阅读(1497)  评论(0编辑  收藏  举报