posted: Nov 28 2008

php-take 2 dates and find out the rest of the dates in between with do-while loop

Tags: , ,

need a way to find all the dates in between? well this currently works with months. but can be adjusted to do days, years, etc. all you need to do is supply a begining date and an end date. it returns an array which can be used for anything,

function between_dates($begin_date, $end_date) {
    $t = date("Y-m",strtotime($begin_date));
       
    $i=0;
    do {
    $my[$i] = date("F Y", (strtotime("{$end_date} +$i months")));
    $mys = date("Y-m", (strtotime("{$end_date} +$i months")));
    $i++;
    }
    while($mys < $t);

    return $my;
}

Your Ad Here



Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes