//Fri Aug 17 2018 00:00:00 GMT+0800 (中国标准时间)
时间转换:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
Date.prototype.format = function(formatStr){
var str = formatStr;
str=str.replace(/yyyy|YYYY/,this.getFullYear());
str=str.replace(/MM/,(this.getMonth()+1)>9?(this.getMonth()+1).toString():'0' + (this.getMonth()+1));
str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate());
return str;
}
alert(new Date().format("yyyy-MM-dd"));
//new Data()获取今天的时间,后续变化只需要把new Data 变为自己想要转换的时间日期即可。
</script>
</body>
</html>