【发布时间】:2013-11-09 09:35:54
【问题描述】:
我正在尝试显示每个月的日期范围。
例如,
2013 年 11 月 -- 2013-11-01 - 2013-11-30 //11 月
2013 年 12 月 -- 2013-12-01 - 2013-12-31 //12 月
2013 年 1 月 -- 2014-01-01 - 2014-01-31 //2014 年 1 月
等到 2014 年 12 月
PHP 代码:
$currentmonth = date('n');
$monthstoloop = $currentmonth + 13;
for ($m=$currentmonth; $m<=$monthstoloop; $m++) {
$month = date('F', mktime(0,0,0,$m, 1, date('Y')));
$year = date('Y', mktime(0,0,0,$m, 1, date('Y')));
echo $month." ".$year;
}
我没有找到在年份旁边显示月份范围的方法。请提出建议。
【问题讨论】: