$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;?>來(lái)讓用戶選月份但是到了01月的時(shí)候會(huì)變成00月如能讓他能往上一年的十二月開(kāi)始選?以及往下一年的一月開(kāi)始選?而不會(huì)有盡頭
2 回答

HUH函數(shù)
TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超4個(gè)贊
if($month == 0)
{
$year--;
$month = 12;
}
if($month == 13)
{
$year++;
$month = 1;
}
- 2 回答
- 0 關(guān)注
- 460 瀏覽
添加回答
舉報(bào)
0/150
提交
取消