zhenguilin / javascript-note

Here are some notes for javascript
https://github.com/zhenguilin/javascript-note
0 stars 0 forks source link

Date #17

Open zhenguilin opened 6 years ago

zhenguilin commented 6 years ago

在JavaScript中,Date对象用来表示日期和时间

var now = new Date();
now; // Wed Jun 24 2015 19:49:22 GMT+0800 (CST)
now.getFullYear(); // 2015, 年份
now.getMonth(); // 5, 月份,注意月份范围是0~11,5表示六月
now.getDate(); // 24, 表示24号
now.getDay(); // 3, 表示星期三
now.getHours(); // 19, 24小时制
now.getMinutes(); // 49, 分钟
now.getSeconds(); // 22, 秒
now.getMilliseconds(); // 875, 毫秒数
now.getTime(); // 1435146562875, 以number形式表示的时间戳