//往new Date里面加一个format(名字随意自定义)扩展方法
Date.prototype.format=function() {
var y= new Date().getFullYear();
var m= new Date().getMonth() + 1;
if(m<10){
m = "0" + m;
}
var d= new Date().getDate();
if(d<10){
d = "0" + d;
}
var h= new Date().getHours();
var mm= new Date().getMinutes();
if(mm<10){
mm = "0" + mm;
}
var s= new Date().getSeconds();
if(s<10){
s = "0" + s;
}
var timestamp = y + "" + m + d + h + mm + s;
return timestamp;
}
var date = new Date().format();
console.log(date);
//例:20160701120633