以下以秒为单位显示时间,并以分钟为单位显示,我如何转换为分钟?
$query = "SELECT * FROM messages WHERE ip = '$ip' AND mtime >= NOW() - INTERVAL 5 MINUTE ORDER by mtime DESC";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
$diff = microtime(true) - $row['mtime']; //here the time difference between last sended message and this try
$remaining = (5*60 - (int) $diff);
echo $remaining;
}
else {
...
}
谢谢。