Date.prototype.format = function (FMT) {
var o = {
"m+": This.getmonth () +1,//month
"D+": this.getdate (),//day
"H +": this.gethours (),//hour
"m+": this.getminutes (),//min
"S+": This.getseconds (),//sec
"q+": Math.floor ((This.getmonth () +3)/3),//Quarterly
"S": this.getmilliseconds ()//MS
};
if (/(y+)/.test (FMT)) {
Fmt=fmt.replace (Regexp.$1, (this.getfullyear () + ""). substr (4-regexp.$1.length));
}
For (var k in O) {
if (New RegExp ("(" + K + ")"). Test (FMT)) {
FMT = Fmt.replace (regexp.$1, (regexp.$1.length==1)? (O[k]): (("XX" + o[k]). substr (("" + O[k]).));
}
}
return FMT;
};
var da = new Date (). GetTime ();
var curtime = new Date (DA). Format ("Yyyy-mm-dd h:m:s");
Console.log (Curtime);
Http://www.cnblogs.com/zhangpengshou/archive/2012/07/19/2599053.html
Http://www.cnblogs.com/tugenhua0707/p/3776808.html
JS Date and Time format conversion method