Jump to content

[SOLVED] difference between months


poe

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/89498-solved-difference-between-months/
Share on other sites

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>';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.