Directly on the code:
//Date formatting functions//yyyy/mm/dd hh:mm:ss sss⇒ "2017/05/16 09:24:20 850"//"yyyy/m/d h:m:s SSS" ⇒ "2017/5/16 9:24:35 723"DATE.PROTOTYPE.FORMAT2 =function(format) {varMap = { ' m+ ': This. GetMonth () + 1, ' D+ ': This. GetDate (),' H + ': This. GetHours (),' m+ ': This. getminutes (),' S+ ': This. getseconds ()}if(/(y+)/i.test (format)) {Format= Format.replace (Regexp.$1, ( This. getFullYear () + "). substr (-regexp.$1. length)); } for(varKinchmap) { if(NewRegExp (' (' + K + ') '). Test (format)) {varstrvalue = Map[k] + "; varLen = Regexp.$1.length < strvalue.length? Strvalue.length:regexp.$1. Length; if(Strvalue.length = = 1) {strvalue= ' 0 ' +strvalue; } format= Format.replace (regexp.$1, Strvalue.substr (-len)); } } if(/(S+)/. Test (format)) {Format= Format.replace (Regexp.$1, ( This. getmilliseconds () + "). substr (0, regexp.$1. length)); } returnformat;}
JS Date Format function