zoukankan      html  css  js  c++  java
  • moment.js获取本周本月本年的开始日期和结束日期

    //获取本日
      const startDate = moment().format('YYYY-MM-DD'); 
      const startDate = moment().format('YYYY-MM-DD');
    //获取本周
     const startDate = moment().week(moment().week()).startOf('week').format('YYYY-MM-DD');   //这样是年月日的格式
     const endDate = moment().week(moment().week()).endOf('week').valueOf(); //这样是时间戳的格式
              
    //获取本月 
      const startDate = moment().month(moment().month()).startOf('month').valueOf();
      const endDate = moment().month(moment().month()).endOf('month').valueOf();
              
     //获取本年
      const startDate = moment().year(moment().year()).startOf('year').valueOf();
      const endDate = moment().year(moment().year()).endOf('year').valueOf();
              
     //获取上月
      const startDate = moment().month(moment().month()).subtract(1,'months').startOf('month').valueOf();
      const endDate = moment().month(moment().month()).subtract(1,'months').endOf('month').valueOf();
  • 相关阅读:
    3.25训练题
    hdu1495
    poj1426 宽搜
    高斯消元
    codeforces 999E 强联通分量
    hdu4289城市与歹徒 网络流
    蒟蒻的离散化模板
    樱花,素数筛
    【转】分圆问题:一个诡异的数列规律
    hdu1257最少拦截系统 贪心
  • 原文地址:https://www.cnblogs.com/z-y-zone/p/12420396.html
Copyright © 2011-2022 走看看