获取下周日之后的星期六日期

时间:2013-03-13 23:59:13

标签: php date

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

2 个答案:

答案 0 :(得分:3)

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

这可以从PHP 4.4开始,参见http://3v4l.org/SUnaR

答案 1 :(得分:1)

试试这个:

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

而不是:

strtotime("next Saturday", $next_sunday)