我在写每周星期一迭代的php脚本。为什么迭代数周会出现PHP日期错误?
但是,脚本似乎在10月22日后不同步。
<?php
$october_8th = strtotime("2012-10-08");
$one_week = 7 * 24 * 60 * 60;
$october_15th = $october_8th + $one_week;
$october_22nd = $october_15th + $one_week;
$october_29th = $october_22nd + $one_week;
$november_5th = $october_29th + $one_week;
echo date("Y-m-d -> l", $october_8th) . '<br />';
echo date("Y-m-d -> l", $october_15th) . '<br />';
echo date("Y-m-d -> l", $october_22nd) . '<br />';
echo date("Y-m-d -> l", $october_29th) . '<br />';
echo date("Y-m-d -> l", $november_5th) . '<br />';
这将输出:
2012-10-08 -> Monday
2012-10-15 -> Monday
2012-10-22 -> Monday
2012-10-28 -> Sunday
2012-11-04 -> Sunday
我希望它说十月29日,但它得到停留在第28位。
我该如何解决这个问题?
谢谢你,这的确是完美的解决方案我一直在寻找。 – 2012-07-28 13:08:15
非常欢迎。玩得开心玩这些课程。 – salathe 2012-07-28 13:08:54