PHP时间函数显示错误的值

PHP时间函数显示错误的值,php,mysql,Php,Mysql,我正在使用以下代码 list($date, $time) = explode(' ', $row['created_at']); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $timemodified = mktime($hour, $minute, $second, $month, $day, $year); $threshold

我正在使用以下代码

list($date, $time) = explode(' ', $row['created_at']);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);
$timemodified = mktime($hour, $minute, $second, $month, $day, $year); 

$threshold = time() - 6;

echo $threshold.'</br>';
echo $timemodified.'</br>';

echo $timemodified - $threshold;
修改后的时间仅为两分钟前。为什么差距如此之大,我只是减去6秒。我错过了什么吗?

这是因为$threshold时间实际上不是6秒。您可以使用strotime函数从时间中减去6秒

$newTime = strtotime('-6 seconds', $timemodified);
echo date('Y-m-d H:i:s', $newTime);

希望这有帮助。我的示例如下:

在哪里提取$hour、$minute、$second、$month、$day、$year??还有$date,$row['created_at']吗?请提供一些样本数据。
$newTime = strtotime('-6 seconds', $timemodified);
echo date('Y-m-d H:i:s', $newTime);