Created
January 16, 2015 21:40
-
-
Save dbarbar/2c4ae12f430aa82e7082 to your computer and use it in GitHub Desktop.
date math fun
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
[1] boris> $period = new DatePeriod(new DateTime('2015-01-31'), new DateInterval('P1M'), 50); | |
// object(DatePeriod)( | |
// 'start' => object(DateTime)( | |
// 'date' => '2015-01-31 00:00:00.000000', | |
// 'timezone_type' => 3, | |
// 'timezone' => 'America/New_York' | |
// ), | |
// 'current' => NULL, | |
// 'end' => NULL, | |
// 'interval' => object(DateInterval)( | |
// 'y' => 0, | |
// 'm' => 1, | |
// 'd' => 0, | |
// 'h' => 0, | |
// 'i' => 0, | |
// 's' => 0, | |
// 'weekday' => 0, | |
// 'weekday_behavior' => 0, | |
// 'first_last_day_of' => 0, | |
// 'invert' => 0, | |
// 'days' => false, | |
// 'special_type' => 0, | |
// 'special_amount' => 0, | |
// 'have_weekday_relative' => 0, | |
// 'have_special_relative' => 0 | |
// ), | |
// 'recurrences' => 51, | |
// 'include_start_date' => true | |
// ) | |
[2] boris> foreach ($period as $thing) { print $thing->format('Y-m-d') . PHP_EOL; } | |
2015-01-31 | |
2015-03-03 | |
2015-04-03 | |
2015-05-03 | |
2015-06-03 | |
2015-07-03 | |
2015-08-03 | |
2015-09-03 | |
2015-10-03 | |
2015-11-03 | |
2015-12-03 | |
2016-01-03 | |
2016-02-03 | |
2016-03-03 | |
2016-04-03 | |
2016-05-03 | |
2016-06-03 | |
2016-07-03 | |
2016-08-03 | |
2016-09-03 | |
2016-10-03 | |
2016-11-03 | |
2016-12-03 | |
2017-01-03 | |
2017-02-03 | |
2017-03-03 | |
2017-04-03 | |
2017-05-03 | |
2017-06-03 | |
2017-07-03 | |
2017-08-03 | |
2017-09-03 | |
2017-10-03 | |
2017-11-03 | |
2017-12-03 | |
2018-01-03 | |
2018-02-03 | |
2018-03-03 | |
2018-04-03 | |
2018-05-03 | |
2018-06-03 | |
2018-07-03 | |
2018-08-03 | |
2018-09-03 | |
2018-10-03 | |
2018-11-03 | |
2018-12-03 | |
2019-01-03 | |
2019-02-03 | |
2019-03-03 | |
2019-04-03 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment