Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. function dty($sdate, $ldate) {
  2. $arr = array();
  3. $start = (new DateTime($sdate))->modify('first day of this month');
  4. $end = (new DateTime($ldate))->modify('first day of next month');
  5. $interval = DateInterval::createFromDateString('1 month');
  6. $period = new DatePeriod($start, $interval, $end);
  7.  
  8.  
  9. foreach ($period as $dt) {
  10. $arr[] = $dt->format("Y-M");
  11. // echo $dt->format("Y-M") . "<br>\n";
  12. }
  13. return $arr;
  14. }
  15. $tt = dty('2013-11', '2015-03');
  16. print_r($tt);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement