解释JavaScript中的Date()对象?
日期()
Date()方法提供当前日期,此外,使用该Date()方法,我们可以获取指定时间格式的日期。
例
<html> <body> <script> var d = new Date(); document.write(d); </script> </body> </html>
输出结果
Thu May 16 2019 05:29:15 GMT+0530 (India Standard Time)
在其中使用newDate()和7个数字,即使是毫秒也可以得到日期。
示例
<html> <body> <script> var d = new Date(2019, 9, 19, 5, 33, 30, 0); document.write(d); </script> </body> </html>
输出结果
Sat Oct 19 2019 05:33:30 GMT+0530 (India Standard Time)
在上面的示例中,我们在日期中用单行给出了年,月,日,小时,分钟,秒,毫秒等。
我们也只能以指定的格式获取时间,例如只有年,月和日的时间为
示例
<html> <body> <script> var d = new Date(2019, 9, 19); document.write(d); </script> </body> </html>
输出结果
Sat Oct 19 2019 00:00:00 GMT+0530 (India Standard Time)
热门推荐
1 训练狗狗搜寻
2 如何训练狗狗装死
3 狗狗训练书
6 怎么训练狗狗拜年
8 狗狗训练游戏
10 狗狗嗅觉训练
11 怎么训练狗狗在笼子里不叫
12 怎么训练狗狗站立走路
13 怎么训练狗狗在马桶上
14 狗狗尿尿怎么训练
15 训练狗狗用品
16 泰迪狗狗的训练方法大小便
17 训练狗狗可以打吗
18 王曼丽的狗狗训练