<分区>
Possible Duplicate:
MYSQL - datetime to seconds
如果我在 mysql 表中有一个 datetime 列,我如何在几秒钟内得到 NOW() 和该列之间的差异?
<分区>
Possible Duplicate:
MYSQL - datetime to seconds
如果我在 mysql 表中有一个 datetime 列,我如何在几秒钟内得到 NOW() 和该列之间的差异?
最佳答案
通过TIMEDIFF
你可以得到以秒为单位的差异
SELECT TIME_TO_SEC(TIMEDIFF('2007-01-09 10:24:46','2007-01-09 10:23:46'));
或者这个
SELECT DATEDIFF('2007-12-31 10:02:00','2007-12-30 12:01:01') * 24*60*60;
// result: 86400 the difference in seconds for days.
或:
SELECT TIMESTAMPDIFF(SECOND,'2007-12-30 12:01:01','2007-12-31 10:02:00');
// result: 79259 the difference in seconds with the time.
关于php - 以秒为单位获取两个 MYSQL 日期时间列之间的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13902579/