new Date(); Date.prototype.Format = function (fmt) { var arr = { "y+": this.getFullYear(), "m+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "M+": this.getMinutes(), "s+": this.getSeconds(), "week": new Array("日", "一", "二", "三", "四", "五", "六")[this.getDay()] }; for (var item in arr) { var val = arr[item] < 10 ? "0" + arr[item] : arr[item]; fmt = fmt.replace(new RegExp(item), val); } return fmt }; setInterval(function () { $("div").html(new Date().Format("yyyy/mm/dd hh:MM:ss 周week")); }, 100);
对现在我的来说有点费解,只能大致明白它的原理...( ⊙ o ⊙ )啊!要疯啦