下周日后获取星期六的日期
问题描述:
我有以下代码,除了$ the_saturday_after_next_sunday之外,一切正常。它没有输出正确的日期。你能帮我正确显示日期吗?下周日后获取星期六的日期
感谢您的帮助。
<?php
$today = date('m/d/Y');
$next_sunday = date('m/d/Y', strtotime("next Sunday"));
$the_saturday_after_next_sunday = date('m/d/Y', strtotime("next Saturday", $next_sunday));
echo "today is: " . $today . "<br>";
echo "next sunday is: " . $next_sunday . "<br>";
echo "the saturday after next sunday is: " . $the_saturday_after_next_sunday . "<br>";
?>
我也试过
$the_saturday_after_next_sunday = strtotime("next Saturday", $next_sunday);
答
$sunday = strtotime("next Sunday");
$saturday = $sunday + 60 * 60 * 24 * 6;
echo date('m/d/Y', $saturday);
这工作,因为PHP 4.4,看到http://3v4l.org/SUnaR
+1
谢谢,这很好用! – cpcdev 2013-03-14 00:16:25
答
试试这个:
strtotime("next Saturday", strtotime($next_sunday))
相反的:
strtotime("next Saturday", $next_sunday)
+0
你认为'strtotime(strtotime(“下周日”))'(本质上是什么)呢? – Wrikken 2013-03-14 00:34:13
[它只是在这里](http://codepad.org/Kcv3Vpfj),你_did_记得正确设置你的时区? – Wrikken 2013-03-14 00:31:48