PHP获取一个月有多少天
2015-12-16 10:38
549 查看
直接上代码:
/*
* 获取当月有多少天
* @param date $unix
* return int
*/
public static function getDaysByMonth($unix){
$month = date('m', $unix);
$year = date('Y', $unix);
$nextMonth = (($month+1)>12) ? 1 : ($month+1);
$year = ($nextMonth>12) ? ($year+1) : $year;
$days = date('d',mktime(0,0,0,$nextMonth,0,$year));
return $days;
}
/*
* 获取当月有多少天
* @param date $unix
* return int
*/
public static function getDaysByMonth($unix){
$month = date('m', $unix);
$year = date('Y', $unix);
$nextMonth = (($month+1)>12) ? 1 : ($month+1);
$year = ($nextMonth>12) ? ($year+1) : $year;
$days = date('d',mktime(0,0,0,$nextMonth,0,$year));
return $days;
}
相关文章推荐
- laravel1
- 制作PHP安装程序的原理和步骤
- 谈谈 PHP7新增功能
- PHP中该怎样防止SQL注入
- PHP 跳转到指定链接
- PHP 编辑环境问题集合
- thinkphp中session设置session周期无效
- SMTP Error: Could not connect to SMTP host
- macOS下php(一)搭建
- ANT:生成doc、打包zip、FTP
- PHP7新特性
- 谈谈PHP中substr和substring的正确用法及相关参数的介绍
- 谈谈 PHP7新增功能
- PHP上传文件参考配置大文件上传
- 通过PHP简单实例介绍文件上传
- 借助PHP的mysql_query()函数来创建MySQL数据库的教程
- 结合PHP脚本添加和查询MySQL数据的基本教程
- php和mysql web开发学习记录
- OLTP和OLAP名称列影响区别
- php中instanceof的作用