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

What is list in PHP?

652


What are the uses of implode() function?

578


What is the role of php.ini file?

561


what is variable scope, which variables are accessible from where and what are "undefined variable" errors?

515


Why is used in php?

530






Which function would you use to replace a record in a database in php?

594


How do you put a space in html?

520


What is the use of dual table in mysql?

526


Which functions are used to count the total number of array elements in php?

550


What is final class and final method in php?

562


What is mvc in php?

539


How can you get the size of an image in PHP?

552


What is reference variable php?

513


What is xss and csrf?

529


What is printf in php?

534