标签:
如图所示:
时间为动态显示。
在你需要的位置插入如下代码即可:
<!--时间调用--> <div style="background: pink;text-align:center;" id="Timer"></div> <script type="text/javascript"> $(function() { setInterval("GetTime()", 1000); }); function GetTime() { var mon, day, now, hour, min, ampm, time, str, tz, end, beg, sec; /* mon = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); */ mon = new Array("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"); /* day = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); */ day = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); now = new Date(); hour = now.getHours(); min = now.getMinutes(); sec = now.getSeconds(); if (hour < 10) { hour = "0" + hour; } if (min < 10) { min = "0" + min; } if (sec < 10) { sec = "0" + sec; } $("#Timer").html( "<nobr>" + now.getFullYear() + "年" + mon[now.getMonth()] + now.getDate() + "日" + " " + hour + ":" + min + ":" + sec + " " + day[now.getDay()] + "</nobr>"); } </script>
时间的显示格式自己可以调整。
为博客园(或网站)添加iquery动态显示时间(格式为:年 月 日 时间 星期几)
标签:
原文地址:http://www.cnblogs.com/dinphy/p/5873966.html