This method expands the format method in the prototype of date, making it easy to format the date format output.
Date.prototype.format =function (format) {varn \ {"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(varKinchOif(NewREGEXP ("("+ K +")"). Test (format)) format= Format.replace (regexp.$1, regexp.$1. length==1?O[k]:("xx"+ O[k]). substr (""+O[k]) (length));returnformat;}
var New Date (parseint ("1347497754133"));d Ate.format ("yyyy-mm-dd ");
Just as seen in the project, there is time to study the principles and parameters.
Time format processing function under DATE.PROTOTYPE.FORMAT,JS