1. 程式人生 > >PHP 獲取指定月對應天數

PHP 獲取指定月對應天數

$firstday = mktime(0,0,0,$month,1,$year); //取所給年月的第一天的UNIX時間戳  
$days = date('t',$firstday); //返回指定月份的天數
$days = cal_days_in_month(CAL_GREGORIAN, 4, 2013);//返回2003-02的天數
$days = date('t', strtotime($year . '-' . $month . '-01'));//返回天數
$ndays = date("t"); //return the number of days for this month and this year
date("j",mktime(0,0,0,$month+1,0,$year));