note 112835 added to function.cal-days-in-month
| From: | asifsajjad at gmail dot com | Date: | Mon, 29 Jul 2013 03:05:44 +0000 |
| Subject: | note 112835 added to function.cal-days-in-month | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195797@lists.php.net to get a copy of this message | ||
count specific days in a month like how many satureday in a monday or how many mondays in a month
<?php
function my_cal_days_in_month($year,$month,$calday="1"){ //0 Sunday, 1 Monday, 2 Tue , 3
Wed , 4. Thu , 5. Fri , 6. Sat
// calculate total number of occurance in this month
$num = cal_days_in_month(CAL_GREGORIAN, $month, $year); // days in month
$dayofweek = date( "w", mktime(0, 0, 0, $month, 1, $year));
$adddays=0;
if($calday > $dayofweek )
$adddays=1 + $calday - $dayofweek;
else if($calday < $dayofweek )
$adddays=1 + 7 + ($calday - $dayofweek );
$remainingdays=$num-$adddays;
$leavesnum=1+intval($remainingdays / 7);
return $leavesnum;
}
$year=2013;
$month=7;
$day=6;
echo my_cal_days_in_month($year,$month,$day);
----
Server IP: 69.147.83.199
Probable Submitter: 122.129.84.121
----
Manual Page -- http://php.net/manual/en/function.cal-days-in-month.php
Edit -- https://master.php.net/note/edit/112835
Del: integrated -- https://master.php.net/note/delete/112835/integrated
Del: useless -- https://master.php.net/note/delete/112835/useless
Del: bad code -- https://master.php.net/note/delete/112835/bad+code
Del: spam -- https://master.php.net/note/delete/112835/spam
Del: non-english -- https://master.php.net/note/delete/112835/non-english
Del: in docs -- https://master.php.net/note/delete/112835/in+docs
Del: other reasons-- https://master.php.net/note/delete/112835
Reject -- https://master.php.net/note/reject/112835
Search -- https://master.php.net/manage/user-notes.php