![]() |
get array of months between 2 dates - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: get array of months between 2 dates (/showthread.php?tid=13599) |
get array of months between 2 dates - El Forum - 11-28-2008 [eluser]new_igniter[/eluser] Hello, Does anyone have a php function for finding the array of months values based on two dates? for example Code: function getMonths('2008-01-01','2008-05-01') { get array of months between 2 dates - El Forum - 11-28-2008 [eluser]xwero[/eluser] Can you define array of months? the simplest way i know would be to strtotime the dates if they are in that format and loop until the month in the future is reached. get array of months between 2 dates - El Forum - 11-28-2008 [eluser]new_igniter[/eluser] I actually just found and used this: http://www.dbforums.com/showthread.php?t=1617949 Thanks for your help get array of months between 2 dates - El Forum - 11-28-2008 [eluser]xwero[/eluser] My solution Code: function get_months($date1, $date2) Another way you could code the function is to let the chronology the dates are added control the sorting of the months, ascending or descending. |