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();
    
  • 相关阅读:
    Git 操作
    SVN
    一维数组
    常见的数学方法
    常用事件
    function函数
    while;do while; for循环
    JS中的变量提升
    关于js的单双引号嵌套问题
    db.collection is not a function
  • 原文地址:https://www.cnblogs.com/lml-lml/p/9935434.html
Copyright © 2011-2022 走看看