how to count how many sundays in month?

Answer Posted / koushikgraj

function total_sundays($month,$year)
{
$sundays=0;
$total_days=cal_days_in_month(CAL_GREGORIAN, $month, $year);
for($i=1;$i<=$total_days;$i++)
if(date('N',strtotime($year.'-'.$month.'-'.$i))==7)
$sundays++;
return $sundays;
}
echo total_sundays(1,2011);

Is This Answer Correct ?    45 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program in php to print a table of a number?

509


What are the types of variables in php?

542


What is the difference between apache vs niginx?

609


What is regex in html?

517


Is uploaded file php?

541






Write a program to find the factorial of a number in php?

533


What is preg_match?

544


Which php framework is fastest?

512


Can a super () and this () keywords be in same constructor?

487


What is "echo" in php?

535


What is a substring in php?

575


What is php session id?

532


Write a program to find a string is palindrome or not?

524


What is the default time of cookie in php?

539


What is get method in java?

535