• 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

  • 相关阅读:
    前后端分类状态下SpringSecurity的玩法
    拓展 centos 7
    linux 日志管理
    Linux 内存监控
    Linux 周期任务
    Linux 文件系统
    linux 磁盘管理
    图论 最短路总结
    进阶线段树之乘法操作
    暑假集训Day 10 小烈送菜
  • 原文地址:https://www.cnblogs.com/xiaonangua/p/14832018.html
Copyright © 2020-2023  润新知