PHP 获取每个月具体的天数

方法1:

$firstday = mktime(0,0,0,$month,1,$year); //取所给年月的第一天的UNIX时间戳    
$days = date('t',$firstday); //返回指定月份的天数  

方法2:

$days = cal_days_in_month(CAL_GREGORIAN, 4, 2013);//返回2003-02的天数  

方法3:

$days = date('t', strtotime($year . '-' . $month . '-01'));//返回天数 

方法4:

$ndays = date("t"); //return the number of days for this month and this year  
date("j",mktime(0,0,0,$month+1,0,$year)); 

 

posted @ 2016-04-20 20:25  ╭(╯3╰)╮尝尝鲜  阅读(1769)  评论(0编辑  收藏  举报