zoukankan      html  css  js  c++  java
  • js Date操作

    new Date(new Date().getTime() - 24 * 24 * 60 * 60 * 1000)
    类似C#中的AddDays,返回一个月前的时间



     //时间格式化方法
            var formatterDate = function (date) {
                var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
                var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"
        + (date.getMonth() + 1);
                return date.getFullYear() + '-' + month + '-' + day;
            };
    使用:
    formatterDate(new Date());
    返回 2016-07-26

    //返回上月时间

    var date= new Date();
    date.setMonth(date.getMonth() - 1)
    console.log(date);

  • 相关阅读:
    web.xml
    web.xml hello1代码分析
    annotation
    injection
    container
    build tool
    version control
    url与uri的区别
    函数式语言
    http协议解析过程
  • 原文地址:https://www.cnblogs.com/gaocong/p/5756662.html
Copyright © 2011-2022 走看看