一,Date

二,Date常用方法
1.getFullYear()

2. getMonth()

3.getDate()

4.getDay()

5.getHours()

6.getMinutes()

7.getSeconds()

二, 时间戳
第一种获取毫秒数的方式
let oDate = new Date();
document.write( '1970年1月1日到现在的毫秒数:'+oDate.getTime() +'<br>');
第二种获取毫秒数的方式
构造函数本身有个方法叫now 执行之后可以获取1970年1月1日到现在的毫秒数
* 推荐使用Date.now()
document.write( '1970年1月1日到现在的毫秒数:'+Date.now() );
本文详细介绍了JavaScript中Date对象的常用方法,包括getFullYear(), getMonth(), getDate(), getDay(), getHours(), getMinutes(), getSeconds()等,用于获取日期和时间信息。同时,讨论了获取时间戳的两种方式:通过Date对象的getTime()方法和使用Date.now()。了解这些基础知识对于JavaScript开发者来说至关重要。
820

被折叠的 条评论
为什么被折叠?



