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
Explain how you can update memcached when you make changes to php?
What is xss in php?
Is null function in php?
How can I load data from a text file into a table?
Explain scalar type declarations in php7?
Is PHP runs on different platforms (Windows, Linux, Unix, etc.)?
Tell me what is the difference between unset() and unlink()?
What are the functions used in php?
How does firefox manage cookies?
What is nan value?
How do you count numbers in php?
How can you propagate a session id?
How to call php function from javascript using ajax?
Tell me what is mean by an associative array?
Is facebook still in php?