$dates = explode("-", $date);
以前的我...
$dates[2]++;
if ($dates[1]=='1'||$dates[1]=='01'||$dates[1]=='3'||$dates[1]=='03'||$dates[1]=='5'||$dates[1]=='05'||$dates[1]=='7'||$dates[1]=='07'||$dates[1]=='8'||$dates[1]=='08'||$dates[1]=='10'){
if ($dates[2]-31 > 0){
$dates[2] = $dates[2] -31;
$dates[1]++;
}
}else if ($dates[1]=='12'){
if ($dates[2]-31 > 0){
$dates[2] = $dates[2] -31;
$dates[1]=1;
$dates[0]++;
}
}else if($dates[1]=='4'||$dates[1]=='04'||$dates[1]=='6'||$dates[1]=='06'||$dates[1]=='9'||$dates[1]=='09'||$dates[1]=='11'){
if ($dates[2]-30 > 0){
$dates[2] = $dates[2] -30;
$dates[1]++;
}
}else if(($dates[0]%4 == 0) &&($dates[1]=='2'||$dates[1]=='02')){
if ($dates[2]-29 > 0){
$dates[2] = $dates[2] -29;
$dates[1]++;
}
}else if(($dates[0]%4 != 0) &&($dates[1]=='2'||$dates[1]=='02')){
if ($dates[2]-28 > 0){
$dates[2] = $dates[2] -28;
$dates[1]++;
}
}
$date = implode("-", $dates);
現在的我...
$date = date("Y-m-d", mktime(0,0,0,$dates[1],$dates[2]+1,$dates[0]));
這就叫做經驗的累積.......唉
沒有留言:
張貼留言