JavaScript date formatting is simple and useful
Code such as the following, after the introduction of jquery directly after adding the following code refresh can be tested
Date.prototype.Format = function (FMT) {//author:meizz var o = { "m+": This.getmonth () + 1,//month "d+": this. GetDate (),//day "H +": this.gethours (),//hour "m+": this.getminutes (),//min "s+": This.getseconds (),//Sec "q+": Math.floor ((This.getmonth () + 3)/3),//Quarterly "S": this.getmilliseconds ()//msec }; if (/(y+)/.test (FMT)) FMT = Fmt.replace (regexp.$1, (this.getfullyear () + ""). substr (4-regexp.$1.length)); For (var k in O) if (New RegExp ("(" + K +) "). Test (FMT)) FMT = Fmt.replace (regexp.$1, (regexp.$1.length = = 1)?(O[k]): (("XX" + o[k]). substr (("" + O[k]).)); return FMT;} $ (function () {var date=new date (); Alert (json.stringify (date). Format ("yyyy mm month dd hh:mm:ss")))
JavaScript date formatting is simple and useful