1.Date对象的四种建立方法分别是什么?ios
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)chrome
2.两个Date对象属性及其做用是什么?函数
constructor:返回对建立此对象的 Date 函数的引用。Date对象的函数原型。firefox
myDate.constructor;
prototype:建立一个新的日期对象方法prototype
Date.prototype.methods
3.经常使用的Date对象方法有哪些?code
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)。