Advertisement
jiue123

Tính ngày làm trong tháng

Sep 11th, 2015
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. function countDays($year, $month, $ignore) {
  2.     $count = 0;
  3.     $counter = mktime(0, 0, 0, $month, 1, $year);
  4.     while (date("n", $counter) == $month) {
  5.         if (in_array(date("w", $counter), $ignore) == false) {
  6.             $count++;
  7.         }
  8.         $counter = strtotime("+1 day", $counter);
  9.     }
  10.     return $count;
  11. }
  12. echo countDays(2015, 9, array(0, 7)); // từ thứ 2->7;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement