zoukankan      html  css  js  c++  java
  • 使用moment获取当前月份最后一天的23点59分

    获取当前月份最后一天

    //1. 先用moment把时间转化为moment时间
    let time=moment("Mon Jun 06 2020 00:00:00 GMT+0800 (中国标准时间)")
    console.log(time);//Moment {_isAMomentObject: true, _i: "Mon Jun 06 2020 00:00:00 GMT+0800 (中国标准时间)", _isUTC: false, _pf: {…}, _locale: Locale, …}
    //2. 使用endOf('')将当前的原始moment时间对象转化为自定义事件单位的末尾 如果用year就是取传入的时间字符串的当年的最后一天
    let time=moment("Mon Jun 01 2020 00:00:00 GMT+0800 (中国标准时间)").endOf('month')
    console.log(time);
    //Moment {_isAMomentObject: true, _i: "Mon Jun 01 2020 00:00:00 GMT+0800 (中国标准时间)", _isUTC: false, _pf: {…}, _locale: Locale, …}
    //_d: Tue Jun 30 2020 23:59:59 GMT+0800 (中国标准时间) {}
    //_i: "Mon Jun 01 2020 00:00:00 GMT+0800 (中国标准时间)"
    //__proto__: Object
    
    //3. 其中_d就是获取到的值 然后再转成时间戳即可
    let time=moment("Mon Jun 01 2020 00:00:00 GMT+0800 (中国标准时间)").endOf('month').unix()
    console.log(time);//1593532799
    
  • 相关阅读:
    AESUtil_1
    ELK配置
    Centos7上安装docker
    Excel大批量数据导出
    Redis5.0.6安装完整步骤
    idea远程打断点
    [HNOI2016] 序列
    [TJOI2017] 异或和
    洛谷 P4933 大师
    洛谷 P1950 长方形_NOI导刊2009提高(2)
  • 原文地址:https://www.cnblogs.com/my466879168/p/13256145.html
Copyright © 2011-2022 走看看