06
Nov
Learn how to use PHP DatePeriod class (PHP 5 >= 5.3.0)
Introduction
Represents a date period.
A date period allows iteration over a set of dates and times, recurring at regular intervals, over a given period.
Just an example to include the end date using the DateTime method.
<?php $begin = new DateTime( '2012-11-01' ); $end = new DateTime( '2012-11-11' ); $end = $end->modify( '+1 day' ); $interval = new DateInterval('P1D'); $daterange = new DatePeriod($begin, $interval ,$end); foreach($daterange as $date){ echo $date->format("Y-m-d") . "<br>"; } ?>
Output
2012-11-01 2012-11-02 2012-11-03 2012-11-04 2012-11-05 2012-11-06 2012-11-07 2012-11-08 2012-11-09 2012-11-10 2012-11-11