how to count how many sundays in month?

Answer Posted / ashish kumar

/* $day = 0 for counting sunday. If you want to count
any other day in a month then set the $day accordingly.
For example $day = 3 for wednesday
*/
$day = 0;
$temp = date('j') - date('w') + $day ;
$count_day_in_a_month = (int)($temp/7) + (int)((date('t') -
$temp)/7) + 1;

Is This Answer Correct ?    13 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is it possible to set an infinite execution time for php script?

523


What is the use of mysql_real_escape_string() function?

521


How would you determine the size of a file in php?

601


How to pass variables by references?

558


What is meant by variable variables in php?

533






How to get ip address of clients machine?

564


Write a program to swap two numbers using php.

544


What is an array in php?

625


Differences between get and post methods?

539


How do you end a session in php?

557


What are the two most common ways to start and finish a php block of code?

638


Why is php so popular?

521


Is php an api?

535


What are different types of Print Functions available in PHP?

532


Which methods should be used for sending an email using the variables $to, $subject, and $body?

568