提供下面的代码,输出是(见下文)。我的问题是为什么在2009/11/01之后,在2009/11/30和2009/12/30之前,而不是2009/12/01。从2009/06/01〜2009/11/01没有问题。本月php的循环日期
输出
2009/06/01
2009/07/01
2009/08/01
2009/09/01
2009/10/01
2009/11/01
2009 /30分之11
2009/12/30
我的代码
<?php
$startdate = "2009/06/01";
$enddate = "2009/12/31";
$start = strtotime($startdate);
$end = strtotime($enddate);
$currentdate = $start;
while($currentdate < $end)
{
$cur_date = date('Y/m/d',$currentdate);
$month = date('m', $currentdate);
$year = date('Y', $currentdate);
$monthLength = daysOfMonth($month, $year);
$currentdate += $monthLength;
echo $cur_date . "<br />";
}
function daysOfMonth($month, $year)
{
return (86400 * date("t", strtotime($year."-".$month."-01")));
}
?>
是阿尔瓦罗的答案是否足够?您应该将其标记为“已接受”或对仍存在问题进行评论。 – philfreo 2009-12-26 04:37:12