Skip to content

Instantly share code, notes, and snippets.

@pjendrusik
Created October 16, 2013 15:46
Show Gist options
  • Save pjendrusik/7010006 to your computer and use it in GitHub Desktop.
Save pjendrusik/7010006 to your computer and use it in GitHub Desktop.
loop for each day between dates
$begin = new DateTime( '2010-05-01' );
$end = new DateTime( '2010-05-10' );
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
foreach ( $period as $dt ){
echo $dt->format( "l Y-m-d H:i:s\n" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment