Advertisement
soywiz

Number of week days per year

Mar 8th, 2011
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2. $date0 = new DateTime('01-01-2011');
  3. $week_days = array();
  4. for ($n = 0; $n < 365; $n++) {
  5.     $date = clone $date0;
  6.     $date->modify('+' . $n . ' days');
  7.     $week_day = $date->format('N');
  8.     @$week_days[$week_day]++;
  9.     //print_r($date);
  10. }
  11.  
  12. print_r($week_days);
  13.  
  14. /*
  15. Array
  16. (
  17.     [6] => 53
  18.     [7] => 52
  19.     [1] => 52
  20.     [2] => 52
  21.     [3] => 52
  22.     [4] => 52
  23.     [5] => 52
  24. )
  25. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement