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 are the advantages of triggers?

1 Answers  


Explain what is the use of "echo" in php?

1 Answers  


I created a cookie with the value like '1A2A',now i want to update this value regularly (about 20 times in a minute) with the value '1A2A3A' , 3A is the new value,new value will vary on the request it may be 3A or 4A or 100A ,some times the cookie is updating with new value but not every time.Can any body suggest the solution

1 Answers  


Can you use both this () and super () in a constructor?

1 Answers  


How can we enable error reporting in php?

1 Answers  


What is csrf validation?

1 Answers  


What are the differences between PHP 3 and PHP 4 and PHP 5?

2 Answers  


What are the different types of errors in PHP?

5 Answers  


What are the differences between Get and post methods in form submitting, give the case where we can use get and we can use post methods?

1 Answers  


how to store case sensitive data in mysql ? how repair mysql table? diff bet float, double,real? diff bet mysql_fetch_object() and mysql_fetch_array()? which version of mysql support procedure , trigger? diff php4 and php 5? op - 2+5+"8"=? how to create object in javascript? query - select games from team who won games 2/4/6? NaN command in php? How to offload System date in mysql? typecasting in php? how to convert string to two decimal no? how to parse xml file in php command line argument in php? diff bet $msg,$$msg? diff bet require(), include(), include_once()? tables in mysql?

2 Answers   Aloha Technology,


What is the output of the following php code?

1 Answers  


What is the difference between mysql_fetch_object and mysql_fetch_array?

10 Answers   Sarv,


Categories