Call us Toll-Free:
1-800-218-1525
Email us

 Sponsors

Get number of days in a given month

Adrian Singer, 12-31-2006
function GetNumOfDaysInMonth($month,$year)
{
$num = 0;
$day = 1;
do
{
@list($loop_month) = split("-",date("m", mktime(0,0,0,$month,$day,$year)));
if ($loop_month!=$month)
{
return $day-1;
}

$day++;
} while (true);

return 0;
}


function GetNumOfMondaysInMonth($month,$year)
{
$num = 0;
$day = 1;
do
{
@list($day_of_week,$loop_month) = split("-",date("w-m", mktime(0,0,0,$month,$day,$year)));
if ($day_of_week==1) $num++;
if ($loop_month!=$month) break;

$day++;
} while (true);

return $num;

}

function GetFirstMondayInMonth($month,$year)
{
$day = 1;
do
{
$day_of_week = date("w", mktime(0,0,0,$month,$day,$year));
if ($day_of_week==1) return $day;
$day++;
} while (true);
}
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions