1、時刻形式
関数getDayFormat(日){ VARの年= date.getFullYear()+ ' - ' ; VAR月=((date.getMonth()+ 1)<10 +(date.getMonth()+ 1) '0':?(date.getMonth()+ 1))+ ' - ' ; VaRの日= date.getDate()<10?'0' + date.getDate():date.getDate(); 戻り年+月+ 日 }
2、タイムスタンプ変換
Date.prototype.Format = 関数(FMT){ // 著者:meizz VAR O = { "M +":この .getMonth()+ 1、 // 月份 "D +":この .getDate() // 日 「H + 「:この .getHours() // 小时 "M +":この .getMinutes() // 分 "S +":この .getSeconds() // 秒 "Q +":数学。床((この .getMonth()+ 3)/ 3)、// 季度 "S":この .getMilliseconds() // 毫秒 }。 もし(/(Y +)/ .TEST(FMT)) FMT = fmt.replace(正規表現$ 1、(。この .getFullYear()+ "").SUBSTR(4 -正規表現$ 1 .LENGTH))。 用(VaRの K でO) であれば(新しい正規表現( "(" + K + ")" ).TEST(FMT)) FMT = fmt.replace(正規表現。$ 1、(正規表現。$ 1.length == 1)?( O [K]):(( "00" + O [K])SUBSTR(( ""O [K])の長さ)))。 リターンのfmt; }。
用途:VAR時間=新しいDate( 'タイムスタンプ値').Format( "YYYY、MM-DD日HH:MM:SS"); //日付