<!DOCTYPE html>
Document
<br> //setInterval("time()",1000)<br> function time(){<br> var date1 = new Date(); //获取当前时间对象;<br> // document.write(date1);<br> var y = date1.getFullYear(); //获取4位数的年<br> var m = date1.getMonth() + 1; //获取月份<br> if (m < 10) {<br> m = "0" + m; //单位数月份凑成双的<br> }<br> var t = date1.getDate();<br> if (t < 10) {<br> t = "0" + t; //单位数月份凑成双的<br> }<br> var w = date1.getDay();<br> if (w == 0) {<br> w = "星期日";<br> } else if (w == 1) {<br> w = "星期一";<br> } else if (w == 2) {<br> w = "星期二";<br> } else if (w == 3) {<br> w = "星期三";<br> } else if (w == 4) {<br> w = "星期四";<br> } else if (w == 5) {<br> w = "星期五";<br> } else if (w == 6) {<br> w = "星期六";<br> }</p> <pre><code> var h = date1.getHours(); if (h < 10) { h = "0" + h; // } var p = date1.getMinutes(); if (p < 10) { p = "0" + p; } var s = date1.getSeconds(); if (s < 10) { s = "0" + s; } var f = y + "年" + m + "月" + t + "日" + w + h + "时" + p + "分" + s + "秒"; // document.write(f); document.getElementById("div1").innerHTML=f } setInterval("time()",1000) </script> </code></pre> <p></head></p> <p><body><br> <div id="div1"></div></p> <p></body></p> <p></html></p>
弑天下
呼唤远方
九州编程
天涯尽头无女友
相关分类