Created
March 6, 2013 06:25
-
-
Save jrmadsen67/5097167 to your computer and use it in GitHub Desktop.
Get preceding 12 month array, starting with 12 months earlier and ending in current month (ex. Today is Mar, so array will be Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,Jan,Feb,Mar)
This file contains 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
$date = new DateTime((date('Y')-1).'-'.date('m').'-01' ); //to kill the 31 day problem | |
$months_array = array_map(function($val) use ($date) {return $date->add(new DateInterval('P1M'))->format('M');}, range(1,12)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment