您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

时间计算有有关问题啊列出最近的前后6个月

2024/2/24 5:54:20发布18次查看
时间计算有问题啊...列出最近的前后6个月
$arr = array();
$nowd = date(ym);
$arr[] = date(ym,strtotime(-6 month));
$arr[] = date(ym,strtotime(-5 month));
$arr[] = date(ym,strtotime(-4 month));
$arr[] = date(ym,strtotime(-3 month));
$arr[] = date(ym,strtotime(-2 month));
$arr[] = date(ym,strtotime(-1 month));
$arr[] = date(ym);
$arr[] = date(ym,strtotime(+1 month));
$arr[] = date(ym,strtotime(+2 month));
$arr[] = date(ym,strtotime(+3 month));
$arr[] = date(ym,strtotime(+4 month));
  $arr[] = date(ym,strtotime(+5 month));
$arr[] = date(ym,strtotime(+6 month));
for($i=0;$i echo .$arr[$i].,;
if($i%3==0)
echo '
';
}
?>
打印出来中间有2个 201203
201204不见了...
只有今天 2012 03 31 全天 的时候出现 平时都是正常的,求分析...
测试的时候请各位把日期设置为3.31号看看.
------解决方案--------------------
还是用你的代码
$nowd = date(y-m-1);
把形如
$arr[] = date(ym,strtotime(-6 month));
都改成形如
$arr[] = date(ym,strtotime(-6 month $nowd));
就可以了
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product