zoukankan      html  css  js  c++  java
  • js 获取上个月的最后一天

    //获取上个月最后一天
    date = new Date();
    console.log(date);
    date.setDate(0); //setDate(day) 方法用于设置一个月的某一天。day取1-31表示对应的天数,另外0 为上一个月的最后一天,-1 为上一个月最后一天之前的一天,32 为下个月的第一天或者第二天
    console.log(date);
    var year = date.getFullYear();
    var month = date.getMonth()+1;
    month = month > 9 ? month:'0'+month;
    var day = date.getDate();  //getDate() 方法可返回月份的某一天。也就是当前date的当前天数
    day = day > 9 ? day:'0'+day;
    console.log("year:"+year+"month:"+month+"day:"+day)
    console.log("---------------------我是分割线------------------------")
    //获取当月第一天
    date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth()+1;
    month = month > 9 ? month:'0'+month;
    console.log("year:"+year+"month:"+month+"day:01")

    转载于:https://www.cnblogs.com/wangylblog/p/13970540.html

  • 相关阅读:
    活动识别API服务开发
    定位服务API案例
    高精地图定位
    HiCar SDK概述
    HiCar人-车-家全场景智慧互联
    AIoT开放平台及应用
    AI+IoT+电池应用
    智能物联网(AIoT,2020年)(下)
    第一课
    分销
  • 原文地址:https://www.cnblogs.com/xiaonangua/p/14832018.html
Copyright © 2011-2022 走看看