我试图计算第一次尝试“$ last_visit”和可能的下一次尝试之间的等待时间可能是第一次30分钟后。PHP当前时间超过未来的时间错误
不知道,但代码返回当前时间大于未来时间时...
<?php
function pa($arr) {
echo '<pre>';
print_r($arr);
echo '< /pre>';
}
$lastv="2014-03-31 02:30:00";
$counter['last']= $lastv." ".strtotime($lastv);
$counter['next']= date('Y-m-d H:i:s', ((strtotime($lastv))+ (30 * 60)))." ".((strtotime($lastv))+ (50 * 60));
$counter['current']= date('Y-m-d h:i:s', time())." ".time();
$counter['wait']=((strtotime($lastv))+ (30 * 60))-time();
pa($counter);
?>
结果
Array
(
[last] => 2014-03-31 02:30:00 1396233000
[next] => 2014-03-31 03:00:00 1396236000
[current] => 2014-03-31 02:57:51 1396277871
[wait] => -43071
)
代码@可运行:http://runnable.com/UzmAZPw7_WxrNqsy/php-time
对不起,你能简单解释一下你想要什么吗? –
我想让用户只有在最后一次尝试30分钟后才能执行操作。问题是我获得的当前时间大于下一次尝试时间(即当前时间之后)。 – user1012345
问题可能会更好地问为:下一次尝试可以在**至少30分钟**后的第一个。即30分钟或更长时间。 –