创建一个日期对象
var date =new Date();
console.log(date);
必须创建一个日期对象才能用这些方法
获取年份
var year= date.getFullYear();
console.log(year);
获取月份 返回的是0-11之间的数, 是指1-12的月份 后+1 即是当年月份
var month =date.getMonth()+1;
console.log(month);
获取日 返回1-31之间的数
var day= date.getDate();
console.log(day);
获取星期 0代表周日 1-6代表周一到周六
var week=date.getDay();
console.log(week);
console.log(year+'/'+month+'/'+day);
获取小时数 返回0-23 0就是24
var hour=date.getHours();
console.log(hour);
获取分钟 返回0-59 0就是60
var minute=date.getMinutes();
console.log(minute);
获取秒 返回0-59 0就是60
var seconds=date.getSeconds();
console.log(seconds);
获取毫秒数 0-999
var milliseconds=date.getMillisecon