Number of days in month using PHP
There might be many situation where we need to find out the total number of days in a month, so that we can create a shift in an company, or create a calender script with notes on some special date and reminders. This sample script will help you to get the total number of days for a specified minth.
function getMonthDays($Month, $Year) {
if( is_callable("cal_days_in_month")) {
return cal_days_in_month(CAL_GREGORIAN, $Month, $Year);
} else {
return date("d",mktime(0,0,0,$Month+1,0,$Year));
}
}
$month=date("m"); // Month of your preference
$year=date("Y"); // Year of your preference
$total_days=getMonthDays($month, $year);
echo "there are $total_days days in the provoded month</br> <a href='http://samplephpcodes.com'>Sample PHP Codes</a>";
Home
See the related postsPHP Warning: Call-time pass-by-reference has been deprecated Working with Database (MySQL) Cookies in PHP Session Management Functions in php Join array elements with a string – implode |




