Last active
March 30, 2017 19:54
-
-
Save plindsay/ab02a4b587abbe936730f33977c93257 to your computer and use it in GitHub Desktop.
DateInterval skips February?..
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
| $begin = new \DateTime('-3 month'); | |
| $end = new \DateTime(date('Y-m-d')); | |
| $end = $end->modify('+1 month'); | |
| $interval = \DateInterval::createFromDateString('+1 month'); | |
| $period = new \DatePeriod($begin, $interval, $end); | |
| foreach($period as $dt) { | |
| $start = $dt->format('Y-m').'-01'; | |
| echo $start."<br>"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment