Copy code code as follows:
/**
* Formulation of time objects;
*/
Date.prototype.Format = Function (format) {
/*
* eg: format = "yyyy-mm-dd Hh: mm: ss";
*/
var o = {
"M +": this.getmonth () + 1, // month
"D+": This.getdate (), // Day
"H+": this.getHours (), // Hour
"m+": this.getminutes (), // minute
"S+": This.getSeconds (), // Second
"q +": math.floor ((this.getmonth ()) + 3), // quarter
"S": This.getmilliseConds ()
// millisecond
}
if (//y+)/.test (Format)) {{
format = format.replace (regexp. $ 1, (this.getfullyear () + "")
.substr (4 -regexp. $ 1.Length);
}
for (var k in o) {
if (new regexp ("(" + k + ")"). Test (format) {
Format = Format.replace (Regexp. $ 1, regexp. $ 1.Length == 1? O [K]
: ("00" + o [k]). Substr (("" + O [K]). LENGTH);
}
}
Return format;
}
Copy code code as follows:
var now = new date (). Format ("yyyy-mm-dd hh: mm: ss");
Copy code code as follows:
new date (). Format ("yy-mm-dd hh: mm");