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)。
    
  • 相关阅读:
    敏捷开发
    开撕队-软件需求规格说明书
    开撕队前来问候
    Four-operations: 使用node.js实现四则运算程序
    wordcount
    编码的故事转载2018-02-28更新
    MySQL学习笔记2018-02-07更新
    Linux各文件及目录说明2018-03-01更新
    Linux安全运维笔记2018-03-01更新
    jQuery实现商品五星评价
  • 原文地址:https://www.cnblogs.com/osmind/p/13308373.html
Copyright © 2011-2022 走看看