var d =newDate();var d1 =newDate('04/20/2021 10:25:34 ');
console.log(d);
console.log(d1);
getFullYear()
该方法可返回一个表示年份的 4 位数字。
console.log('年份 : '+d.getFullYear());
getMonth() 从对象中返回月份[0是一月以此类推]
console.log('月份 : '+d.getMonth());
getDay()
getDay() 方法可返回一周(0~6)的某一天的数字。
**注意: 星期天为 0, 星期一为 1, 以此类推。**
console.log('周几 : '+d.getDay());-getDate()- 从 Date 对象返回一个月中的某一天(1~31)。
```javascript
console.log('天数 : '+d.getDate());
getHours()
返回Date对象中的小时【0~23】
console.log('小时 : '+d.getHours());
getMinutes() 方法可返回时间的分钟字段。
console.log('分钟 : '+d.getMinutes());
getSeconds() 方法可返回时间的秒。
console.log('秒数 : '+d.getSeconds());
getMilliseconds() 方法可返回时间的毫秒。
console.log('毫秒 : '+d.getMilliseconds());
getTime() 返回1970年1月1日至今的毫秒数;
console.log('1970年1月1日至今的毫秒数 : '+d.getTime());
获取当前时间戳
var time = Date.now();
console.log(time);
可以用来测试代码执行的时间
var start = Date.now();
document.write('<br>');var sum =0;for(i=1;i<10000;i++){
sum += i;}
document.write(sum);
document.write('<br>');var end = Date.now();
document.write( end-start);