Copiar código del código de la siguiente manera:
/**
* Formulación de objetos de tiempo;
*/
Date.prototype.format = function (format) {
/*
* por ejemplo: format = "aaa-mm-dd hh: mm: ss";
*/
var o = {
"M +": this.getMonth () + 1, // mes
"D+": this.getDate (), // Day
"H+": this.gethours (), // hora
"M+": this.getminutes (), // minuto
"S+": this.getSeconds (), // segundo
"Q +": Math.floor ((this.getMonth ()) + 3), // trimestre
"S": this.getMilliseConds ()
// milisegundo
}
if (//y+)/.test (format)) {{
format = format.replace (regexp. $ 1, (this.getfulfyear () + "")
.substr (4 -regexp. $ 1.Length);
}
para (var k en o) {
if (new Regexp ("(" + K + ")"). Test (Format) {
Format = format.replace (regexp. $ 1, regexp. $ 1.length == 1? O [k]
: ("00" + o [k]).
}
}
Formato de retorno;
}
Copiar código del código de la siguiente manera:
var ahora = nueva fecha ().
Copiar código del código de la siguiente manera:
nueva fecha ().