Copy Code code as follows:
Date.prototype.format = function (format)
{
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)/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]: ("+ o[k]"). substr (("" + o[k]). length);
}
}
return format;
}
var testdate = new Date (1320336000000);//Here must be an integer, MS
var teststr = Testdate.format ("yyyy mm month DD Day hh hour mm minute ss seconds");
var testStr2 = Testdate.format ("YyyyMMdd hh:mm:ss");
Alert (Teststr + "" + testStr2);