php获取某年某月的天数

function days_in_month($month, $year) {
    // calculate number of days in a month
    return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}

echo days_in_month(2,2014);

输出:28

 

转自:http://www.cnblogs.com/freespider/p/3545885.html

你可能感兴趣的:(PHP)