var OverView = OverView || {} Date.prototype.format = function(format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.getSeconds(), //second "q+": Math.floor((this.getMonth() + 3) / 3), //quarter 季度 "S": this.getMilliseconds() //millisecond } //返回年的值 if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); } for (var k in o) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); } } return format; } OverView.getdate = function() { var a = new Array("日", "一", "二", "三", "四", "五", "六"); var week = new Date().getDay(); var str = a[week];//获取星期几 var date = new Date().format("yyyy年MM月dd日")//返回对应格式的年月日 var time = new Date().format("hh:mm:ss")//返回对应格式的时分秒 $("#timecontainer").empty(); $("#timecontainer").append('<div style="width:60%;height:100%;display:inline-block;padding-left:10px"><span style="font-size:5.0em">' + time + '</span></div><div style="width: 40%; height: 100%; display: inline-block; font-size: 1.5em;vertical-align:top;padding-top:20px;padding-left:15px;"><span style="display:inline-block">星期' + str + '</span><br /><span style="display: inline-block">' + date + '</span></div>') }