取得目前月份的上個月或下個月,
主要是使用strtotime(),來作目前月份的加減。
http://php.net/manual/en/function.strtotime.php
$YM = isset($_POST['YM']) ? $_POST['YM'] : date('Y-m');
$YMD = "$YM-01";
switch($_POST['type']){
default:
case 'curr'://目前月份
break;
case 'next'://下個月
$YM = date("Y-m", strtotime('+1 month',strtotime($YMD)));
break;
case 'prev'://上個月
$YM = date("Y-m", strtotime('-1 month',strtotime($YMD)));
break;
}
沒有留言:
張貼留言