我可以知道如何计算php中特定日期时间剩余的时间吗?
示例我希望用户可以在30分钟后请求新的确认码。
$request_date = '2012-03-24 13:03:17';
$please_wait = '30 minutes';
如何计算剩余时间?
答案 0 :(得分:1)
strtotime("+" . $please_wait, strtotime($request_date));
尝试
php> $request_date = '2012-03-24 13:03:17';
php> $please_wait = '30 minutes';
php> echo strtotime("+" . $please_wait, strtotime($request_date));
1332576197
答案 1 :(得分:1)
$thirty_minutes_in_the_future = strtotime('+30 minutes', strtotime($request_date));
答案 2 :(得分:1)
计算请求的时间戳并用当前时间戳减去
解决方案:
$future = strtotime($request_date)+1800; // 1800 is 30 minutes
echo date("i", $future-time()); //this is the remaining minutes
答案 3 :(得分:1)
新确认码的剩余时间:
$request_date = '2012-03-24 13:03:17';
$please_wait = '30 minutes';
$future_time = strtotime("+" . $please_wait, strtotime($request_date));
$time_left = $future_time - time(); //seconds left