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

Tell me how is it possible to propagate a session id?

599


Does php need a closing tag?

545


What are properties in php?

510


What are the differences between require and include?

567


How do I run a php script in windows?

549






How to get ip address of clients machine?

559


Tell me what is the use of mysql_real_escape_string() function?

535


How do I check if a given variable is empty?

526


What is an associative array?

553


Tell me how can we determine whether a php variable is an instantiated object of a certain class?

556


What is difference between ksort() and usort() functions.

520


Write logic to print Floyd's triangle in PHP?

540


Tell me what are the __construct() and __destruct() methods in a php class?

502


What are the four scalar types of php?

613


What is action hooks and filter hooks?

490