zoukankan      html  css  js  c++  java
  • Date对象和Time对象

    方法 描述
     getDate()  ; setDate()  返回/设置月份中的日期(1-31)
     getDay()  返回星期几(0-6)
     getFullYear();setFullYear()  返回/设置年份(4位数字)
     getHours();setHours()  返回/设置小时(O-23)
     getMillseconds();setMilliseconds()  返回/设置毫秒数(0-999)
     getMinutes()setMinutes()  返回/设置分钟(0-59)
     getMonth()setMonth()  返回/设置月份(0-11)
     getSeconds()setSeconds)  返回/设置秒(0-59)
     getTime()setTime()  从1970年1月1日0点00:00:00UTC(世界标准时间)开始计算的毫秒数。如果是这之前的时间,返回一个负数
     getTimezoneOfset()  按分钟为本地时间返回时区偏差值
     toDateString()  返回适合人类阅读的日期
     toTimeString()  返回适合人类阅读的时间
    toString()   返回表示特定日期的字符串

    Date对象在使用时前需要先实例化,采用构造函数实例化。

    var today=new Date();
    

      

    // toTimeString 将时间转换成人看得懂的
    document.write(today.toTimeString(today.getTime()));
    document.write('<br>');
    

    生成指定的日期

    var lastDate=new Date('1998-12-12T12:23:45');
    document.write(lastDate.toDateString(lastDate.getTime()));
    document.write('<br>');
    document.write(lastDate.toTimeString(lastDate.getTime()));
    document.write('<br>');
    

      

     
  • 相关阅读:
    后缀数组-另辟蹊径
    Project Euler 不定期更新
    Educational Codeforces Round 93 (Rated for Div. 2)
    Codeforces Round #664 (Div. 2)
    lower_bound和upper_bound的用法
    Codeforces Round #663 (Div. 2)
    Codeforces Round #661 (Div. 3)
    质数笔记
    C++运算符的优先级
    图的构建
  • 原文地址:https://www.cnblogs.com/max-hou/p/8867784.html
Copyright © 2011-2022 走看看