0

我有以下代码,除了 $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); 
4

2 回答 2

3
$sunday   = strtotime("next Sunday");
$saturday = $sunday + 60 * 60 * 24 * 6;
echo date('m/d/Y', $saturday);

这从 PHP 4.4 开始有效,请参阅http://3v4l.org/SUnaR

于 2013-03-14T00:12:05.730 回答
1

试试这个:

strtotime("next Saturday", strtotime($next_sunday))

代替:

strtotime("next Saturday", $next_sunday)
于 2013-03-14T00:13:57.847 回答