List all dates within date range in PHP

The function to get all dates which falls under the date range specified (i.e. your start date and end date).
It uses PHP DateTime Class to get the result and tested with PHP 5.3

function _daterange_days($start_date, $end_date, $format = 'Ymd')
     $begin = new DateTime($start_date);
     $end = new DateTime($end_date);
     $end = $end->modify( '+1 day' );

     $result = array();
     $daterange = new DatePeriod($begin, new DateInterval('P1D'), $end);
     foreach($daterange as $date)
          $result[] = $date->format($format);
     return $result;

Continue reading “List all dates within date range in PHP”

Hello world!

Welcome… my first post @

Earlier to this I had many several blogs and unfortunately all are closed now for some reasons.. mainly for uplifting my career in IT. So didn’t had much time to share the things.

Hello world!Now will try putting my best effort to make this live. So keep reading and keep connected!