new Date() // 获取当前时间---北京时间
![](https://img.haomeiwen.com/i8989637/9c78e73b54036a2b.png)
let nowDate =new Date();
![](https://img.haomeiwen.com/i8989637/4d30468c225808d7.png)
nowDate.getFullYear();//获取完整的年份(4位)
![](https://img.haomeiwen.com/i8989637/2667b485bf8265e9.png)
nowDate.getMonth();//获取当前月份(0-11,0代表1月)
![](https://img.haomeiwen.com/i8989637/3b82a3eaeb30dcb7.png)
nowDate.getDate();//获取当前日(1-31)
![](https://img.haomeiwen.com/i8989637/548ee3ebf4405ccb.png)
nowDate.getDay();//获取当前星期X(0-6,0代表星期天)
![](https://img.haomeiwen.com/i8989637/d6d6b88f76eda0b0.png)
nowDate.getTime();//获取当前时间(时间戳)
![](https://img.haomeiwen.com/i8989637/6cebe31fb194ccc5.png)
nowDate.getHours();//获取当前小时数(0-23)
![](https://img.haomeiwen.com/i8989637/5fd9e314938efb1e.png)
nowDate.getMinutes();//获取当前分钟数(0-59)
![](https://img.haomeiwen.com/i8989637/f8a11ffb71bbdc5d.png)
nowDate.getSeconds();//获取当前秒数(0-59)
![](https://img.haomeiwen.com/i8989637/e94649b11505da88.png)
nowDate.getMilliseconds();//获取当前毫秒数(0-999)
![](https://img.haomeiwen.com/i8989637/6975bb98d1e65689.png)
nowDate.toLocaleDateString();//获取当前日期
![](https://img.haomeiwen.com/i8989637/839f852799ccdff3.png)
nowDate.toLocaleTimeString();//获取当前时间
![](https://img.haomeiwen.com/i8989637/63408b80ec947ffc.png)
nowDate.toLocaleString( );//获取日期与时间
![](https://img.haomeiwen.com/i8989637/8995f36194785c1d.png)
网友评论