Copier le code du code comme suit:
/ **
* Formulation des objets temporels;
* /
Date.prototype.format = fonction (format) {
/ *
* par exemple: format = "yyyy-mm-dd hh: mm: ss";
* /
var o = {
"M +": this.getMonth () + 1, // mois
"D +": this.getDate (), // jour
"H +": this.gethours (), // heure
"M +": this.getMinutes (), // minute
"S +": this.getSeconds (), // seconde
"q +": math.floor ((this.getMonth ()) + 3), // trimestre
"S": this.getMilliseconds ()
// milliseconde
}
if (//y+)/.test (format)) {{
format = format.replace (regexp. 1 $, (this.getlyar () + "")
.Substr (4 -regexp. 1, $ Length);
}
pour (var k dans o) {
if (new regexp ("(" + k + ")"). test (format) {
Format = format.replace (regexp. 1 $, regexp. 1 1.Length == 1? O [k]
: ("00" + o [k]).
}
}
Format de retour;
}
Copier le code du code comme suit:
var now = new Date ().
Copier le code du code comme suit:
Nouvelle date ().