可能重複:
What is best solution to get next and previous month from given date php在PHP下一個和上月從某月
我開發PHP中的工作。在這裏,我想下一個和上月從某月例如:
$mth="December"
我想提前
感謝
可能重複:
What is best solution to get next and previous month from given date php在PHP下一個和上月從某月
我開發PHP中的工作。在這裏,我想下一個和上月從某月例如:
$mth="December"
我想提前
感謝
$mth="December";
$next_mth = Date("F", strtotime($mth . " next month"));
$pre_mth = Date("F", strtotime($mth . " last month"));
這應該做月的下一個和以前顯示:
$date = new DateTime();
$date->modify('+ 1 month');
print $date->format("F"); // next
$date->modify('- 2 month');
print $date->format("F"); // previously
看看這個也得到這些東西的方法
$mth="December";
$nxt = date('F',mktime(0,0,0,date("m", strtotime($mth))+2,null,null));
$pre = date('F',mktime(0,0,0,date("m", strtotime($mth))-0,null,null));
echo $pre.'-'.$mth.'-'.$nxt;