'use strict';
Date.prototype.format = function(format) {
// yyyy-mm-dd HH:mm:ss
if (typeof format !== 'string') return;
let dateStr = format;
let year = this.getFullYear();
let month = this.getMonth();
let day = this.getDate();
let hour = this.getHours();
let minute = this.getMinutes();
let seconds = this.getSeconds();
function add0(value) {
return value < 10 ? '0' + value : '' + value;
}
month = add0(month);
day = add0(day);
hour = add0(hour);
minute = add0(minute);
seconds = add0(seconds);
dateStr = dateStr.replace(/yyyy/, '' + year);
dateStr = dateStr.replace(/MM/, '' + month);
dateStr = dateStr.replace(/dd/, '' + day);
dateStr = dateStr.replace(/HH/, '' + hour);
dateStr = dateStr.replace(/mm/, '' + minute);
dateStr = dateStr.replace(/ss/, '' + seconds);
return dateStr;
};
console