Pass the frequency and current date to get an array of dates.
eg.
getDatesForYear(4,'2011-01-01');
the array you get will have the following dates
"2011-04-30","2011-08-31","2011-12-31"
public function getDatesForYear($monthlyFequency,$date){ $dateParts = explode("-",$date); $firstDayOfTheYear = $dateParts[0] . '-01-01'; $lastDayOfTheYear = $dateParts[0] . '-12-31'; $i = $firstDayOfTheYear; for(strtotime($i);strtotime($i)<=strtotime($lastDayOfTheYear);) { $accruDate[] = date('Y-m-d',strtotime($i . " +$monthlyFequency months -1 day ")) ; $i = date('Y-m-d',strtotime($i . " +$monthlyFequency months")); } return $accruDate; }
No comments:
Post a Comment