Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.