// Extend the date to string // month (M), Day (D), hour (H), and minute (m) in the specified format), second (s), quarter (q) can use 1-2 placeholders, // year (y) can use 1-4 placeholders, Millisecond (s) only one placeholder (a number ranging from 1 to 3) can be used. // example: // (new date ()). format ("yyyy-mm-dd hh: mm: Ss. s ") => 08:09:04. 423 // (new date ()). format ("yyyy-m-d h: M: S. s ") ==>. 18 date. prototype. format = function (FMT) {var o = {"m +": This. getmonth () + 1, // month "d +": This. getdate (), // Day "H +": This. get Hours (), // Hour "m +": This. getminutes (), // minute "s +": This. getseconds (), // second "q +": math. floor (this. getmonth () + 3)/3), // quarter "S": This. getmilliseconds () // millisecond}, K; If (/(Y + )/. test (FMT) FMt = FMT. replace (Regexp. $1, (this. getfullyear () + ""). substr (4-Regexp. $1. length); For (K in O) {If (New Regexp ("(" + K + ")"). test (FMT) FMt = FMT. replace (Regexp. $1, (Regexp. $1. length = 1 )? (O [k]): ("00" + O [k]). substr ("" + O [k]). length);} return FMT ;}
Date Format, timestamp format