how to count how many sundays in month?

Answers were Sorted based on User's Feedback



how to count how many sundays in month?..

Answer / uk

mr Aravind And ms Divya..this place is not for u guys (to
play) i guess..If u dont know the answer better watch out
for one, dont play the fool around.

Is This Answer Correct ?    69 Yes 12 No

how to count how many sundays in month?..

Answer / 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

how to count how many sundays in month?..

Answer / 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

how to count how many sundays in month?..

Answer / 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

how to count how many sundays in month?..

Answer / divya

Sundays are not meant to count. Its meant to freak.

Is This Answer Correct ?    12 Yes 27 No

how to count how many sundays in month?..

Answer / aravindraj

just sit under the calendar and u will see the month in
that. Red marked days are sunday in calendar.

Is This Answer Correct ?    34 Yes 61 No

Post New Answer

More PHP Interview Questions

What is the use of preg_match in php?

0 Answers  


How do you create an array in php?

0 Answers  


How to find the length of a string?

0 Answers  


How can we know that a session is started or not? Rushmore-Consultancy 3 why we use @symbol before the variable HCL 3 How can you insert javascript in php code? TCS 9 How can you parse files that were not ending with .php by using Apache? 1 What is the difference between InnoDb tables and MyIsam Tables in php 1 Hi all, I have a problem in Apache on windows xp.I tried to unistall apache and install it again. But when in did the installation again, and tried to run apache, i get the following error message, Socketaddresse can just be used once. Make_sock: could not build to address 0.0.0.0.80 No listening sockets available.Shutting down Unable to open logs. and i also get (error) OS2. The system cannot fine the installed service named "Apache2". Please i need some one to help me out with this.I'm really fustrated cuz i need this stuff working as fast as possible. PLEASE HELP ME 2 1.Where are the sessions storing ? 2.What are the contents of a session file ? 3.If the server is loaded with too many session files there is a possibility of server crash. How can we solve this issue? 4. How does php server identify that the particular session belongs to particular user ? For ex: If two users A and B logged from different machine, separate session files (say 1 and 2) will be created in the server. But how the php knows that 1 belongs to A and 2 belongs to B ? TCS 3 How to send Email using PHP with MySQL in Linux Server?.. 3 Write a query to to delete duplicate rows? 3 How i can integrate merchant payment get way in zen cart? in php? plz help me BA-Continnum-Solutions 1 how to maintained the session from one page to another page based on the url and then entered into the first page is logging into instead of secondpage it goes to the another url.ie first login session togoes to the one url and next login session it goes to another url how is it possible in php please give me answer in that question iCynergy 1 Is there a way to encrypt text from php? 4 What’s the difference between sort(), assort() and ksort? Under what circumstances would you use each of these? 1 Write the code for upload a video file in PHP.How will You Play this in Your Page.? Convex-Digital 2 how to select the multiple data in selection button xasis-technologies 1 what are the current or latest versions of LAMP ? Linux, Apache, MySql, PHP 3 WWhat is the functionality of md5 function in PHP? 6 how php works with oracle? 1 what mode to use when creating dirs with mkdir? 1 How to upload a file (may be a .txt or a .doc file) from a php script/file? 1 For more PHP Interview Questions Click Here Copyright Policy | Terms of Service | Help | Site Map 1 | Articles | Site Map | Site Map | Contact Us | interview questions urls External Links

3 Answers   eMantras, HCL,


What does php exit do?

0 Answers  






How are sessions maintained?

0 Answers  


How to return ascii value of character in php?

0 Answers  


What is php? Why it is used?

0 Answers  


How to know user has read the email-php?

0 Answers  


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

0 Answers  


What is the use of 'print' in php?

0 Answers  


What is a PHP accelerator?

0 Answers  


Categories