我有一个MYSQL查询,它选择所有小于60天的行。我想在我的PHP页面上显示“x天和y小时左”。最简单的方法是什么?
SELECT u.username, u.id, u.score, s.genre, s.songid, s.songTitle, s.timeSubmitted, s.userid, s.insWanted, s.bounty, COUNT(p.songid)
FROM songs s
LEFT JOIN users u
ON u.id = s.userid
LEFT JOIN posttracks p
ON s.songid = p.songid
WHERE paid=1 AND s.timeSubmitted >= ( CURDATE() - INTERVAL 60 DAY )
GROUP BY s.timeSubmitted DESC
LIMIT 15
答案 0 :(得分:1)
尝试TIMEDIFF()
。
答案 1 :(得分:1)
在PHP中,在循环遍历行时尝试沿着这些行:
$then = strtotime($futureDateAsString);
$diff = $then - time();
echo sprintf("%s days and %s hours left", date('z', $diff), date('G', $diff));