• You won’t believe it, but this is EXACTLY what I needed. Very well done :-)

  • Glad it was of use. :) Extensive functions for dates and time in PHP are awesome to make snippets this short, but accurate.

  • topala

    very useful!! thank you very much :)

  • Thank you! Lots of bad examples out there, but this one was very short and clean. Great, this’ll become handy! Thanks :-)

  • Pk Anane

    you have know idea how awesome this is..there’s just so much convulated info on the web.. thanks..my app can proceed

  • mahdi

    thanks for your nice code. it is useful but how can i skip weedend?

  • @mahdi

    I don’t see the point of including weekend logic in this code. You can always loop through the range afterward and exclude days that fall on weekends.

  • $start = implode('-', array_reverse( explode("/",$start_date) ) );
    $stop = implode('-', array_reverse( explode("/",$end_date) ) );
    $arDates = array();
    $begin = new DateTime($start );
    $end = new DateTime( $stop );
    $end = $end->modify( '+1 day' );

    $interval = new DateInterval('P1D');
    $daterange = new DatePeriod($begin, $interval ,$end);

    foreach($daterange as $date){
    $arDates[] = $date->format("Y-m-d");
    return $arDates;

  • Matteo

    Just PERFECT!

    thanks a lot!

  • steve

    absolute god send, thank you so much

Comments are closed.