javascript显示年月日时间代码

javascript显示年月日时间代码

<script language=Javascript> 
  function time(){
    //获得显示时间的div
    t_div = document.getElementById('showtime');
   var now=new Date()
    //替换div内容 
   t_div.innerHTML = "现在是"+now.getFullYear()
    +"年"+(now.getMonth()+1)+"月"+now.getDate()
    +"日"+now.getHours()+"时"+now.getMinutes()
    +"分"+now.getSeconds()+"秒";
    //等待一秒钟后调用time方法,由于settimeout在time方法内,所以可以无限调用
   setTimeout(time,1000);
  }
</script>

演示: https://bgm.pw/assets/file/zp/20251214184712.html

2025-12-14 18:47:34 通过 网页 浏览(39)

共有0条评论!

发表评论

更换一道题!