将毫秒转换为xxxx-xx-xx格式日期
function timeChange(time){
var newTime = new Date(time) ;
Date.prototype.toLocaleString = function() {
return this.getFullYear() + "-" + (this.getMonth() + 1) + "-" + this.getDate();
};
return newTime.toLocaleString();
}
将当前时间转换为XXXX-XX-XX格式
function timeChange(){
var curTime = new Date() ;
Date.prototype.toLocaleString = function() {
var curMonth = this.getMonth() + 1 ;
var curDate = this.getDate();
if(curMonth>=1 && curMonth<=9){
curMonth = "0" + curMonth;
}
if(curDate>=1 && curDate<=9){
curDate = "0" + curDate;
}
return this.getFullYear() + "-" + curMonth + "-" + curDate;
};
return curTime.toLocaleString();
}