poe Posted February 5, 2008 Share Posted February 5, 2008 this is probably simple math but watching back to back episodes of jeopardy my brain is a little fried ??? if ih have 2 different months / with years how do i calculate the difference in terms of months like: start = 03-2006 end = 02-2008 what i am really trying to do is create an array of months that are between these 2 dates, including by year. ie. mar'06, apr06, may06, jun06, jul06 ...... dec07, jan08, feb08 Quote Link to comment https://forums.phpfreaks.com/topic/89498-solved-difference-between-months/ Share on other sites More sharing options...
Barand Posted February 5, 2008 Share Posted February 5, 2008 try <?php $start = strtotime ('2006-03-01'); $end = strtotime ('2008-02-01'); $months = array(); while ($start <= $end) { $months[] = date('m-Y', $start); $start = strtotime ('+1 month', $start); } //result echo '<pre>', print_r($months, true), '</pre>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/89498-solved-difference-between-months/#findComment-458480 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.