其实方法很简单: // 时间转时间戳 //方法一: var timeStamp_1 = new Date().getTime(); console.log(timeStamp_1); //方法二: var timeStamp_2 = (new Date()).valueOf(); console.log(timeStamp_2); //方法三: var timeStamp_3 = Number(new Date()); console.log(timeStamp_3); //时间戳转换成对象 function formatDate(now){ now=new Date(now); var year=now.getFullYear(); var month=now.getMonth()+1; var date=now.getDate(); return year+"-"+month+"-"+date; }