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)。

posted on 2020-07-15 21:52  mindos  阅读(201)  评论(0编辑  收藏  举报

导航