Next and previous month from this month in php

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

+2
source share
3 answers
 $mth="December"; $next_mth = Date("F", strtotime($mth . " next month")); $pre_mth = Date("F", strtotime($mth . " last month")); 
+2
source

This should do:

 $date = new DateTime(); $date->modify('+ 1 month'); print $date->format("F"); // next $date->modify('- 2 month'); print $date->format("F"); // previously 
+2
source

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; 
0
source

All Articles