建議學習時長: 30分鐘
學習方式:了解
學習目標
- 了解日期的常用方法
詳細介紹
Date
對象是 JavaScript
提供的日期和時間的操作接口签钩。
日期這塊只需了解。用的時候來查閱即可翘贮。對于復雜的日期操作盗誊,可以用第三方庫Moment.js逝钥。
常用方法
初始化
- new Date ()
- new Date (str)
- new Date (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] )
日期對象上的操作
- getTime
- getFullYear
- getMonth
- getDate
- getHours
- getMinutes
- getSeconds
靜態(tài)對象
- Date.now()