Advertisement
krot

дата за указанный период по дням недели

Mar 16th, 2018
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $from = new DateTime('2018-01-11');
  5. $to   = new DateTime('2018-04-20');
  6.  
  7. $period = new DatePeriod($from, new DateInterval('P1D'), $to);
  8.  
  9. $arrayOfDates = array_map(
  10.     function($item){
  11.         return array(
  12.             strtr(
  13.                 $item->format('w'),
  14.                 array("вс", "пн","вт","ср","чт","пт","сб")
  15.             )
  16.             ,
  17.             $item->format('Y-m-d')
  18.             );
  19.    
  20.     },
  21.     iterator_to_array($period)
  22. );
  23.  
  24. print_r($arrayOfDates);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement