获取当日是否是当月最后一天
2017-03-08 15:53
225 查看
/*
* author:houdianjing date:2017-3-7
* 获取当日是否是当月最后一天
* 返回:1为是月末最后一天 0为不是最后一天
*/
方法一:
function gettheday()
{
date_default_timezone_set('Asia/Shanghai');
$getDay = date('d'); //获取当日几号
$date=date('Y-m-d H:i:s'); //当前时间
$firstday = date('Y-m-01', strtotime($date));
$lastday = date('d', strtotime("$firstday +1 month -1 day"));//获取当月最后一天
if($getDay==$lastday){
return 1;
}else{
return 0;
}
}
方法二:
function gettheday()
{
date_default_timezone_set('Asia/Shanghai');
$getMonth = date('m'); //获取当前月份
$date=date('Y-m-d H:i:s'); //当前时间转时间戳
$nextMonth = date('m', strtotime("$date +1 day"));//当前日期加1天后 获取月份
if($getMonth<>$nextMonth){//如果加1后的月份还和当前月份相等,则不是最后一天
return 1;
}else{
return 0;
}
}
* author:houdianjing date:2017-3-7
* 获取当日是否是当月最后一天
* 返回:1为是月末最后一天 0为不是最后一天
*/
方法一:
function gettheday()
{
date_default_timezone_set('Asia/Shanghai');
$getDay = date('d'); //获取当日几号
$date=date('Y-m-d H:i:s'); //当前时间
$firstday = date('Y-m-01', strtotime($date));
$lastday = date('d', strtotime("$firstday +1 month -1 day"));//获取当月最后一天
if($getDay==$lastday){
return 1;
}else{
return 0;
}
}
方法二:
function gettheday()
{
date_default_timezone_set('Asia/Shanghai');
$getMonth = date('m'); //获取当前月份
$date=date('Y-m-d H:i:s'); //当前时间转时间戳
$nextMonth = date('m', strtotime("$date +1 day"));//当前日期加1天后 获取月份
if($getMonth<>$nextMonth){//如果加1后的月份还和当前月份相等,则不是最后一天
return 1;
}else{
return 0;
}
}
相关文章推荐
- 获取当日当周当月当年的第一天最后一天
- Java日期循环,Java获取当月的第一天和最后一天
- js获取当月的最后一天
- js 获取当月的第一天和最后一天
- java 获取当前年份 月份,当月第一天和最后一天
- js获取当月第一天和最后一天
- SQL Server 下的 获取当月最后一天
- ASP.NET C#如何获取当月的第一天和最后一天
- SQL中获取当月的最后一天
- js获取当月最后一天实例代码
- 【转载】java利用 Calendar获取当月最后一天
- js获取当月的最后一天
- asp.net获取当月第一天和最后一天的方法
- Java日期循环,Java获取当月的第一天和最后一天
- ASP.NET C#如何获取当月的第一天和最后一天
- js获取当月的最后一天
- java获取当月的第一天和最后一天
- pb获取当月最后一天
- java利用 Calendar获取当月最后一天
- java 获取当月第一天和最后一天 获取前一个月第一天和最后一天