zoukankan      html  css  js  c++  java
  • java script 日期对象Date()

    java script 日期对象Date()

    1.获取当前时间

      var time = new Date()

      document.write(time);  

      注意:如果Date() 有参数的话  返回1970年1月1日到指定毫秒数的时间

         当参数为 n,q,w时  n代表年 q 代表月 q代表天   其中实际月份会比参数月份+1

    2.Date.now()获取当前时间戳

      document.write(Date.now())      获取当前时间距离1970年1月1日的毫秒数

      var a = new Date()

      document.write(a.getTime());     结果一样

      注意 :document.write(time); 获取的当前时间    Date.now()获取当前时间距离1970年1月1日的毫秒数

    3.Date.parse()返回1970年1月1号到指定时间日期的毫秒数

      console.log(Date.parse(2015,09,26,12,23,34)); 

      参数:为年月日时分秒   Date.UTC() 国际指定日期时间到1970年1月1日。

    4.获取当前的年月日时分秒分开储存

        console.log(d.getFullYear());
        console.log(d.getMonth()+1); //获取月份
        console.log(d.getDate()); //获取当前日
        console.log(d.getDay()); //星期几(0是星期日)
        console.log(d.getHours());
        console.log(d.getMinutes());
        console.log(d.getSeconds());
        console.log(d.getMilliseconds());
        console.log(d.getTime());

  • 相关阅读:
    Navicat 连接MySQL 8.0.11 出现2059错误
    安全技术运营的心得
    浅谈命令混淆
    2021年度总结与2022新的展望
    域环境搭建之安装exchange
    内网ADCS攻防
    CVE202142287复现
    企业安全建设——安全防线框架建设(一)
    frp_v0.37.1内网穿透,内网服务公网用不求人
    WP7XNA 多点触摸
  • 原文地址:https://www.cnblogs.com/stt520/p/9591765.html
Copyright © 2011-2022 走看看