zoukankan      html  css  js  c++  java
  • js 获取今天以及前一周/前20天时间

    var end = new Date();
    var start = new Date();
    console.log('==========今天=============')
    console.log(start);
    console.log(end);
    console.log('==========今天=============')
    console.log(start.getFullYear());
    console.log(start.getMonth());
    console.log(start.getDate());
    console.log('==========20天前=============')
    start.setDate(start.getDate() - 20);   //day和month会自动计算到上一个月的
    console.log(start.getFullYear());
    console.log(start.getMonth());
    console.log(start.getDate());
    
    
    var startYear = start.getFullYear();
    var startMonth = start.getMonth() + 1 >= 10 ? start.getMonth() + 1 : "0" + (start.getMonth() + 1);
    var startDate = start.getDate() >= 10 ? start.getDate() : "0" + start.getDate();
    
    var endYear = end.getFullYear();
    var endtMonth = end.getMonth() + 1 >= 10 ? end.getMonth() + 1 : "0" + (end.getMonth() + 1);
    var endDate = end.getDate() >= 10 ? end.getDate() : "0" + end.getDate();
    startDate1 = startYear + "-" + startMonth + "-" + startDate;
    endDate1 = endYear + "-" + endtMonth + "-" + endDate;
    console.log(startDate1);
    console.log(endDate1)
    

      console输出:

  • 相关阅读:
    es操作
    MySQL逻辑架构
    ceshimd
    mysql资料
    已解决 : VMware Workstation 与 Hyper-V 不兼容。请先从系统中移除 Hyper-V 角色
    MySQL数据库操作
    phpstorm配置laravel语法提示
    MySQL日志之慢查询日志(slow-log)
    456
    topcoder srm 553
  • 原文地址:https://www.cnblogs.com/Andrew520/p/9317308.html
Copyright © 2011-2022 走看看