var date = new Date(); var year = date.getFullYear(); //返回月份小1,需要加1 var month = date.getMonth()+1; var date = date.getDate()+5; var dates = year + '-' + month + '-' + date; console.log(dates) var date = new Date(); var hour = date.getHours(); var min = date.getMinutes(); var sec = date.getSeconds(); var times = hour +":"+min+":"+sec; console.log(times) //返回Date的总毫秒数 //方法一通过valueOf getTime() var date = new Date(); console.log(date.valueOf()); console.log(date.getTime()); //方法二简单的写法(最常用的写法) var date1 = +new Date(); console.log(date1); //方法3 h5新增的获取总毫秒数 console.log(Date.now());