Created
May 13, 2016 00:58
-
-
Save turtlix/67578f1301772fc83d49aeb826b1fce0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$start_date = new DateTime('2010-10-01'); | |
$end_date = new DateTime('2010-10-05'); | |
$period = new DatePeriod( | |
$start_date, // 1st PARAM: start date | |
new DateInterval('P1D'), // 2nd PARAM: interval (1 day interval in this case) | |
$end_date, // 3rd PARAM: end date | |
DatePeriod::EXCLUDE_START_DATE // 4th PARAM (optional): self-explanatory | |
); | |
foreach($period as $date) { | |
echo $date->format('Y-m-d').'<br/>'; // Display the dates in yyyy-mm-dd format | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment