//这里以2015年11月为例$inputs['month'] = '201511';//传递过来的参数$tmp_month = $inputs['month'].01;//$tmp_month = '20151101';$s_time = strtotime($tmp_month);//月起始时间$e_time = strtotime(date(ymd,$s_time).'+1 month');//月结束时间$countmins = ($e_time - $s_time)/60;//当月分钟数$countday = $countmins/(60*24);//当月的天数
但是现在,发现了更好的获取方法。
php内置函数date(),可以直接获取当月天数。
$tmp_month = $inputs['month'].01;$countday = date(t,strtotime($tmp_month));//如果直接date(t),得到的是当月的天数
so easy!
其实,还有一个方法,使用cal_days_in_month()函数,php手册中给的解释是:返回某个历法中某年中某月的天数。
3个参数:
calendar 用来计算的某个历法
month 选定历法中的某月
year 选定历法中的某年
$num = cal_days_in_month(cal_gregorian, 11, 2015); // 30
我个人还是比较喜欢date()函数的,这样不用考虑历法的问题。
').addclass('pre-numbering').hide(); $(this).addclass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadein(1700); }); }); 以上就介绍了php中,获取指定日期的当月天数,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
