Skip to content

Instantly share code, notes, and snippets.

@oboshto
Created February 2, 2017 10:57
Show Gist options
  • Select an option

  • Save oboshto/24aa563fdef8a54e97bf61377b8f53cb to your computer and use it in GitHub Desktop.

Select an option

Save oboshto/24aa563fdef8a54e97bf61377b8f53cb to your computer and use it in GitHub Desktop.
Just an example to include the end date using the DateTime method 'modify'
<?php
$begin = new DateTime( '2012-08-01' );
$end = new DateTime( '2012-08-31' );
$end = $end->modify( '+1 day' );
$interval = new DateInterval('P1D');
$daterange = new DatePeriod($begin, $interval ,$end);
foreach($daterange as $date){
echo $date->format("Ymd") . "<br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment