zoukankan      html  css  js  c++  java
  • js 获取时间对象代码

    /**
    * 获取时间对象
    */
    function getDateObj(addDayCount) {
    var dd = new Date();
    dd.setDate(dd.getDate()+addDayCount);//获取addDayCount天后的日期
    var y = dd.getFullYear();
    var m = dd.getMonth()+1;//获取当前月份的日期
    var d = dd.getDate();
    var h = dd.getHours();
    var M = dd.getMinutes();
    var s = dd.getSeconds();

    var w = "";
    var numOfWeek = dd.getDay();
    switch (numOfWeek) {
    case 0: w = "星期日"; break;
    case 1: w = "星期一"; break;
    case 2: w = "星期二"; break;
    case 3: w = "星期三"; break;
    case 4: w = "星期四"; break;
    case 5: w = "星期五"; break;
    case 6: w = "星期六"; break;
    }

    var timeObject = {
    'year' : y,
    'month' : m,
    'day' : d,
    'hour' : h,
    'minute': M,
    'second': s,
    'week' : w
    }
    return timeObject;
    }

    window.ready = function(){

    var t = getDateObj(1);
    alert(t.year + '-' +
    t.month + '-' +
    t.day + ' ' +
    t.hour + ':' +
    t.minute + ':' +
    t.second + ' ' +
    t.week);

    }

  • 相关阅读:
    2021广东省强网杯WriteUp
    2021 数字四川创新大赛WriteUp
    2021 陇剑杯wp
    2021 羊城杯WriteUP
    如何翻安全四大顶会的文章
    2021 祥云杯 wp
    codeql初探
    sqlmap应用
    sql注入2
    sql注入
  • 原文地址:https://www.cnblogs.com/tancp/p/3847564.html
Copyright © 2011-2022 走看看