一、Js代码
function getTime(){
str = "当前系统时间:"
var p = document.getElementById("sy_time");
time = new Date();
year = time.getFullYear();
month = time.getMonth() + 1;
day = time.getDate();
hour = time.getHours();
minutes = time.getMinutes();
seconds = time.getSeconds();
str = str + year +"-"+ month +"-"+ day + " " +hour+":"+minutes+":"+seconds;
p.innerText = str;
setTimeout(getTime,1000);
}
window.onload = function(){
getTime();
}
二、前端代码
<!-- 页面调用代码 -->
<p id = "sy_time"></p>
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did289