时间:2020-12-11 21:16:23 | 栏目:JavaScript代码 | 点击:次
一、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>