zoukankan      html  css  js  c++  java
  • 年月日,时分秒,星期

    var now = new Date(); //当前时间

    var nowYear = now.getFullYear(); //当前年

    var nowMonth = now.getMonth() +1; //当前月(0-11,0代表1月)

    var nowDate = now .getDate(); //当前日(1-31)

    var weekArr = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")

    var weekDay = weekArr[now.getDate()]  //当前星期

    var nowHour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();  //当前小时

    var nowMinute = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();  //当前分钟

    var nowSecond = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds(); //当前秒

    var nowMilliseconds  = now.getMilliseconds(); //当前毫秒数(0-999)

    var myDate = now.toLocaleDateString(); //获取当前日期

    var mytime = now.toLocaleTimeString(); //获取当前时间

    var myDayTime = date .toLocaleString( ); //获取日期与时间

    code by trister
  • 相关阅读:
    例5-6
    例5-5
    例5-4
    例4-5
    例4-4
    例4-3
    例4-2
    例3-11
    例3-10
    例3-9
  • 原文地址:https://www.cnblogs.com/tristers/p/12869252.html
Copyright © 2011-2022 走看看