peterjc Posted September 4, 2008 Share Posted September 4, 2008 I know to get the next month based on today date example: date('Y-m-d',strtotime('1 months')) will get the date for next month from today. But know i want to get the next month based on a specific date. Example, i want to get the date for next month based on this date: 2008-06-04. So it will output 2008-07-04. Thank in advance. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 4, 2008 Share Posted September 4, 2008 Take a look at mktime(). Quote Link to comment Share on other sites More sharing options...
peterjc Posted September 4, 2008 Author Share Posted September 4, 2008 Thank for you replay. But how to use the mktime() to make the date one month later? Thank. Quote Link to comment Share on other sites More sharing options...
Fadion Posted September 4, 2008 Share Posted September 4, 2008 You can use mktime() in this way: <?php $date = '2008-06-04'; list($year, $month, $day) = explode('-', $date); $next = date('Y-m-d', mktime(0, 0, 0, $month + 1, $day, $year)); echo $next; ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2008 Share Posted September 4, 2008 You can do this directly in strtotime (and in fact strtotime uses mktime internally) - $any_date = "2008-06-04"; echo date('Y-m-d',strtotime("$any_date + 1 months")); Quote Link to comment Share on other sites More sharing options...
peterjc Posted September 5, 2008 Author Share Posted September 5, 2008 Oh. thank a lot for all the reply. I really appreciate it. It solve my problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.