var myDate = new Date();
console.log(myDate);//获取当前标准时间
console.log("获取当前是周"+ myDate.getDay());//星期日是0
console.log("获取当前月份是"+ (myDate.getMonth() + 1) +"月");//从12月开始
console.log("获取当前日期是"+ myDate.getDate() +"号");
console.log("获取当前年份是" + myDate.getFullYear() +"年");
console.log("获取当前小时是" + myDate.getHours() + "时");
console.log("获取当前分钟是" + myDate.getMinutes() + "分");
console.log("获取当前秒是" + myDate.getSeconds() + "秒");
console.log("获取当前毫秒是" + myDate.getMilliseconds() + "毫秒");
console.log("获取从1970/01/01午夜累计的毫秒数是" + myDate.getTime() + "毫秒");//时间戳
//定义指定时间(定义格式兼容性比较好)
var newDate = new Date("2018/05/05 00:00:00");
console.log(newDate);