Skip to content

Commit

Permalink
Update base.html
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntek authored Sep 19, 2017
1 parent 743b462 commit 1a6f7c3
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,27 @@
<script src="../static/js/demo/peity-demo.js"></script>

<script>
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
Date.prototype.format = function (fmt) {
var args = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds()
};
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]) : (("00" + o[k]).substr(("" + o[k]).length)));
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var i in args) {
var n = args[i];
if (new RegExp("(" + i + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
}
return fmt;
}
};
function showTime() {
today = new Date().Format("yyyy-M-d h:m:s");
today = new Date().format("yyyy-MM-dd hh:mm:ss");
document.getElementById("local").innerHTML = today;
}
setInterval("showTime()", 1000);
Expand Down

0 comments on commit 1a6f7c3

Please sign in to comment.