JS Date Time formatted extension:
1Date.prototype.format =function (FMT) {2 varo = {3 "m+": This. GetMonth () +1,//Month4 "d+": This. GetDate (),//Day5 "H +": This. GetHours ()% A==0? A: This. GetHours ()% A,//when6 "H +": This. GetHours (),//hours7 "m+": This. getminutes (),//points8 "s+": This. getseconds (),//seconds9 "q+": Math.floor (( This. GetMonth () +3) /3),//seasonTen "S": This. Getmilliseconds ()//milliseconds One }; A varWeek = { - "0":"\u65e5", - "1":"\u4e00", the "2":"\u4e8c", - "3":"\u4e09", - "4":"\u56db", - "5":"\u4e94", + "6":"\u516d" - }; + if(/(y+)/. Test (FMT)) { AFMT = Fmt.replace (regexp.$1, ( This. getFullYear () +""). substr (4-regexp.$1. length)); at } - if(/(e+)/. Test (FMT)) { -FMT = Fmt.replace (regexp.$1, ((regexp.$1. length >1) ? (regexp.$1. length >2?"\u661f\u671f":"\u5468") :"") + week[ This. GetDay () +""]); - } - for(varKincho) { - if(NewREGEXP ("("+ K +")"). Test (FMT)) { inFMT = Fmt.replace (regexp.$1, (regexp.$1. length = =1) ? (O[k]): (("xx"+ O[k]). substr (""+O[k] )); - } to } + returnFMT; -}
Here's how to use it:
var date = new Date ("2016-03-11t16:20:12");
$ ("#divResult"). HTML (Date.format ("Yyyy-mm-dd EE HH:mm:ss"));
JS Date Time formatted extension