js小应用之设定当前系统时间 博客分类: javaScript JavaScript系统日期时间
程序员文章站
2024-03-16 19:20:28
...
代码:
-
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> <div id="time_bar"></div> <script type="text/javascript"> var od = function(){}; od.prototype.oc = new Array('日','一','二','三','四','五','六'); od.prototype.w = function (b){ return this.oc[b]; } od.prototype.h = function(t){ if(t<10)return '0'+t; return t; } var d = new od(); var r = function run (){ var now =new Date().getFullYear()+'年' + (new Date().getMonth()+1)+'月' + new Date().getDate()+'日'+' ' + '星期'+d.w(new Date().getDay())+' '+ d.h(new Date().getHours())+':'+ d.h(new Date().getMinutes())+':'+ d.h(new Date().getSeconds()); document.getElementById("time_bar").innerHTML = now; } r(); setInterval(r,1000) ; </script> </body> </html>
-