$date = strtotime(date("Y-m-d"));
$day = date('d', $date);
$month = str_pad($_GET['m'],2,'0',STR_PAD_LEFT);
$year = date('Y', $date);
$firstDay = mktime(0,0,0,$month, 1, $year);
$title = strftime('%m', $firstDay);
$dayOfWeek = date('D', $firstDay);
$daysInMonth = cal_days_in_month(0, $month, $year);
$timestamp = strtotime('next Sunday');
$weekDays = array('日', '一', '二', '三', '四', '五', '六');
for ($i = 0; $i < 7; $i++){
$timestamp = strtotime('+1 day', $timestamp);
}
$blank = date('w', strtotime("{$year}-{$month}-01"));
<td><?if($_GET['m']!='01'){?><a class="monthLink" href="?m=<?=str_pad($month-1,2,'0',STR_PAD_LEFT);?>&y=<?=$year;?>®ion=<?=$_GET['region'];?>">← <?=$month-1;?>月</a><?}?></td>
我是用<?=$month-1;?> 或 <?=$month+1;?>來讓用戶選月份但是到了01月的時候會變成00月如能讓他能往上一年的十二月開始選?以及往下一年的一月開始選?而不會有盡頭
2 回答
HUH函数
TA贡献1836条经验 获得超4个赞
if($month == 0)
{
$year--;
$month = 12;
}
if($month == 13)
{
$year++;
$month = 1;
}
- 2 回答
- 0 关注
- 443 浏览
添加回答
举报
0/150
提交
取消