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. Link to comment https://forums.phpfreaks.com/topic/122673-get-next-month-based-on-specifc-date/ Share on other sites More sharing options...
JasonLewis Posted September 4, 2008 Share Posted September 4, 2008 Take a look at mktime(). Link to comment https://forums.phpfreaks.com/topic/122673-get-next-month-based-on-specifc-date/#findComment-633455 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. Link to comment https://forums.phpfreaks.com/topic/122673-get-next-month-based-on-specifc-date/#findComment-633493 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; ?> Link to comment https://forums.phpfreaks.com/topic/122673-get-next-month-based-on-specifc-date/#findComment-633499 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")); Link to comment https://forums.phpfreaks.com/topic/122673-get-next-month-based-on-specifc-date/#findComment-633585 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. Link to comment https://forums.phpfreaks.com/topic/122673-get-next-month-based-on-specifc-date/#findComment-634146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.