zoukankan      html  css  js  c++  java
  • JS——Date日期对象

    1.Date对象的四种创建方法分别是什么?

    
    new Date()
    
    new Date(milliseconds)
    
    new Date(dateString)
    
    new Date(year,month,day,hours,minutes,seconds,milliseconds)
    
    

    1.1 dateString时间字符串的三种格式格式
    通用格式:年/月/日 空格 时:分:秒(示例:2020/07/15 16:53:56)
    短横杆式:xxxx-xx-xx xx:xx:xx(chrome firefox opera)
    斜杆式:xxxx/xx/xx xx:xx:xx(chrome firefox opera safari ios(苹果手机只认此格式))
    点式:xxxx.xx.xx xx:xx:xx(chrome opera)

    2.两个Date对象属性及其作用是什么?

    constructor:返回对创建此对象的 Date 函数的引用。Date对象的函数原型。

    myDate.constructor;
    

    prototype:创建一个新的日期对象方法

    Date.prototype.methods
    

    3.常用的Date对象方法有哪些?

    getFullYear()	      从 Date 对象以四位数字返回年份。
    getMonth()	      从 Date 对象返回月份 (0 ~ 11)。
    getDate()	      从 Date 对象返回一个月中的某一天 (1 ~ 31)。
    getHours()	      返回 Date 对象的小时 (0 ~ 23)。
    getMinutes()	      返回 Date 对象的分钟 (0 ~ 59)。
    getSeconds()	      返回 Date 对象的秒数 (0 ~ 59)。
    getMilliseconds()     返回 Date 对象的毫秒(0 ~ 999)。
    
    getTime()	      返回 1970 年 1 月 1 日至今的毫秒数。
    getDay()	      从 Date 对象返回一周中的某一天 (0 ~ 6)。
    
  • 相关阅读:
    【坑】提答题
    Google Code Jam 2014 Round2
    湖北省队互测Week1
    [xyz模拟题]动态维护树的直径
    音乐会的等待【单调栈】
    51nod1202【DP-树状数组维护】
    51nod1113【矩阵快速幂】
    51nod1255【贪心-栈的应用】
    Lightoj1059【最小生成树】
    SPOJ IAPCR2F 【并查集】
  • 原文地址:https://www.cnblogs.com/osmind/p/13308373.html
Copyright © 2011-2022 走看看