PHP: Get all of the dates between two dates

July 24, 2008 – 10:24 am

I'm having trouble explaining this...

This function returns an array of all of the days between two dates. EG: Give it 2008-07-23 and 2008-07-25, and it will return an array containing, 2008-07-23, 2008-07-24, and 2008-07-25.

If you give it an interval, like years, it will give you an array of dates, on per year, between the two dates you specify.

 
// An array of days between two days, intervals is days, weeks, months, years
function get_days($start, $end, $interval = 'days') {
 
  $days[] = $start;
 
  $current = $start;
 
  while($current < $end){
    $current = gmdate("Y-m-d", strtotime("+1 $interval", strtotime($current)));
    $days[] = $current;
  }
 
  return $days;
}
 

Post a Comment



thevedic.net

Part of the thevedic.net.
[Contact Me] - [Mud Emporium] - [Ozark, AR] - [See my Port?]

This site is in no way represents the opinions or positions of any company or organization including those who employ the creators of this web site. We're not responsible for the content, posts, responses by other users or ideas of any sites that are linked to on this page. This site is recommended for ages 18 and up.

VEDIC VEKO IS PROSPEROUS

Arkie Imports | Dean Vaughan | Dean Vaughan | K. Dean Vaughan | Kenneth Vaughan | Pig Trail 23 | Pig Trail Pics | See My Port Forward Info | See My Port Forward Info


I'm not affiliated with the following in anyway.
Arkansas MMA - Inferno Mixed Martial Arts - Inferno Martial Arts Club - Inferno Martial Arts Club - Official Inferno Fight Gear - Inferno Fight Equipment - Inferno Combat Gear - IFC Online - Inferno Fight Gear - Inferno MMA - Inferno Fight Gear