js格式化日期
Date.prototype.toLocaleString = function() { var mon = (this.getMonth() + 1)+''; var month = mon.length==1?'0'+mon:mon; var da = this.getDate()+''; var day = da.length==1?'0'+da:da; var hours = this.getHours()+''; var hour = hours.length==1?'0'+hours:hours; var min = this.getMinutes()+''; var minutes = min.length==1?'0'+min:min; return this.getFullYear() + "-" + month + "-" + day+ " " + hour + ":" + minutes; }; //使用方法 new Date().toLocaleString();