how to count how many sundays in month?

Answer Posted / vinayan

$n=1;
$yy=date("Y");
//$day=strftime("%A");
$day1=getdate(mktime(0,0,0,01,01,$yy));
$day=$day1[weekday];
switch($day)
{

case Sunday:$n=0;
break;
case Monday:$n=$n+6;
break;
case Tuesday:$n=$n+5;;
break;
case Wednesday:$n=$n+4;;
break;
case Thursday:$n=$n+3;;
break;
case Friday:$n=$n+2;;
break;
case Saturday:$n=$n+1;;
break;
}
$yy=date("Y");
$mon=12;
$day=31;
$curyear=$yy."-".$mon."-".$day;
$timeStamp = strtotime($yy."-01-00");
$timeStamp += 24 * 60 * 60 * $n; // (add 7 days)
$newDate = date("Y-m-d", $timeStamp);

Is This Answer Correct ?    21 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between $_files['userfile']['name'] and $_files['userfile']['tmp_name']?

537


What is binary safe function in php?

580


How can cross site request forgery csrf be prevented?

489


What are the methods of array in java?

495


What is apache and php?

496






What is mean tnq

1087


Which php framework is best for beginners?

511


What are php magic methods?

524


Does php support overloading?

574


What are the advantages of php mysql?

521


What are headers in php?

529


In PHP, fgets() is used to read a file one line at a time. State Whether True or False?

586


Please explain is it possible to use com component in php?

560


What is the use of magic function in php?

506


How stop the execution of a php scrip?

532