Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to calculate number of Sundays of a particular month and year?

user-image
Question added by Faizan Ahmad , Software Engineer , cardekho.com
Date Posted: 2013/04/07
Zaid Rabab'a
by Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.

function countSundays($year, $month, $ignore) { $count = 0; $counter = mktime(0, 0, 0, $month, 1, $year); while (date("n", $counter) == $month) { if (in_array(date("w", $counter), $ignore) == false) { $count++; } $counter = strtotime("+1 day", $counter); } return $count; } echo countDays(2013, 1, array(0, 6));

More Questions Like This