Skip to content

Instantly share code, notes, and snippets.

@tbsmcd
Created July 13, 2012 09:12
Show Gist options
  • Save tbsmcd/3103807 to your computer and use it in GitHub Desktop.
Save tbsmcd/3103807 to your computer and use it in GitHub Desktop.
13fri3
$period = new DatePeriod(
new Datetime('2012-01-13'),
new DateInterval('P1M'),
new Datetime('2012-12-13')
);
foreach ($period as $day) {
echo $day->format('Y-m-d') . PHP_EOL;
}
// 2012-01-13
// 2012-02-13
// 2012-03-13
// 2012-04-13
// 2012-05-13
// 2012-06-13
// 2012-07-13
// 2012-08-13
// 2012-09-13
// 2012-10-13
// 2012-11-13
$period = new DatePeriod(
new Datetime('2012-01-13'),
new DateInterval('P1M'),
new Datetime('2012-12-13 00:00:01')
);
foreach ($period as $day) {
echo $day->format('Y-m-d') . PHP_EOL;
}
// 2012-01-13
// 2012-02-13
// 2012-03-13
// 2012-04-13
// 2012-05-13
// 2012-06-13
// 2012-07-13
// 2012-08-13
// 2012-09-13
// 2012-10-13
// 2012-11-13
// 2012-12-13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment