zoukankan      html  css  js  c++  java
  • 获取当日是否是当月最后一天

    /*
    * 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;
    }
    }

  • 相关阅读:
    nodejs下载图片保存本地
    anaconda基本命令
    1.购买腾讯学生服务器遇到的坑
    git 命令
    JS深拷贝递归实现
    Object.prototype.toString()
    Spring核心知识点
    Spring核心知识点
    Spring核心知识点
    Spring基础知识点
  • 原文地址:https://www.cnblogs.com/houdj/p/6519824.html
Copyright © 2011-2022 走看看