[code=php] //我来列出一年的所有日期.
// header("Content-type:text/html; charset=utf-8");
//上面这句是我注释掉的,不然会报错,提示已经指定编码,诡异~~
$date1 = '2008-12-31';
$time1=strtotime($date1);
$y = date("Y",$time1+86000*8);
for ($a =1; $a<366;$a++)
{
$d = date("d",$time1+=(3600*24));
$m = date("m",$time1);
echo $y.'年'.$m.'月'.$d." ";
if (in_array($m,array(1,3,5,7,8,10,12))) {
$s[$a]=$m;
if(count($s)==31){
echo '
';
unset($s);
}
}elseif ($m!=2) {
$s[$a]=$m;
if(count($s)==30){
echo '
';
unset($s);
}
}else {
$s[$a]=$m;
if(count($s)==28){
echo '
';
unset($s);
}
}
if($a%7==0)echo '
';
}
?>
[/code]
转载请注明:鸟儿博客 » 列出一年中所有的日期