动态显示当前时间

<script>
function showTime(){
    nowtime=new Date();
    year=nowtime.getFullYear();
    month=nowtime.getMonth()+1;
    date=nowtime.getDate();
    document.getElementById("timeShow").innerText=year+"年"+month+"月"+date+"日";
}
setInterval("showTime()",1000);
</script>
下面写一个id为timeShow的div就可以了 显示为XXXX年XX月XX日

猜你喜欢

转载自blog.csdn.net/c_y_w_/article/details/80866073