Possible duplicate:What is the best solution to get next and previous month from a given php date
I am developing work in php. Here I want to get the next and previous month from a specific month, for example:
$mth="December"
I want to show next and previous December
Thank you in advance
$mth="December"; $next_mth = Date("F", strtotime($mth . " next month")); $pre_mth = Date("F", strtotime($mth . " last month"));
This should do:
$date = new DateTime(); $date->modify('+ 1 month'); print $date->format("F"); // next $date->modify('- 2 month'); print $date->format("F"); // previously
Check it out too to get these materials.
$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;