方案一:
//传入当前年份跟月份$data = date('d',strtotime($code['year'].'-'.($code['month']+1).'-1')-60*60*24);
方案二:
//传入的参数也是当前年份跟月份$oldtime = $years_time."-".$month;//获取月初和月末的时间戳function getMonth($date){// 获取到当月的第一天时间戳$firstday = date("Y-m-01",strtotime($date));// string(10) "2018-07-31" 获取到当月的最后天$lastday = date("Y-m-d",strtotime("$firstday +1 month -1 day"));// 将第一天转为时间戳$firstday = strtotime($date);// 最后一天转为时间戳$lastday = strtotime($lastday);// 获取当月天数$day_sum = (($lastday - $firstday)/86400);return array($firstday,$lastday,$day_sum);}
