| Date. prototype. Format = function (formatStr ){ Var str = formatStr; Var Week = ['day', 'yi', '2', '3', '4', '5', '6']; Str = str. replace (/yyyy | YYYY/, this. getFullYear ()); Str = str. replace (/yy | YY/, (this. getYear () % 100)> 9? (This. getYear () % 100). toString (): '0' + (this. getYear () % 100 )); Str = str. replace (/MM/, (this. getMonth () + 1)> 9? (This. getMonth () + 1). toString (): '0' + (this. getMonth () + 1 )); Str = str. replace (/M/g, (this. getMonth () + 1 )); Str = str. replace (/w | W/g, Week [this. getDay ()]); Str = str. replace (/dd | DD/, this. getDate ()> 9? This. getDate (). toString (): '0' + this. getDate ()); Str = str. replace (/d | D/g, this. getDate ()); Str = str. replace (/hh | HH/, this. getHours ()> 9? This. getHours (). toString (): '0' + this. getHours ()); Str = str. replace (/h | H/g, this. getHours ()); Str = str. replace (/mm/, this. getMinutes ()> 9? This. getMinutes (). toString (): '0' + this. getMinutes ()); Str = str. replace (/m/g, this. getMinutes ()); Str = str. replace (/ss | SS/, this. getSeconds ()> 9? This. getSeconds (). toString (): '0' + this. getSeconds ()); Str = str. replace (/s | S/g, this. getSeconds ()); Return str } |