javascript显示年月日时间代码

来源:互联网 发布:sql初学者指南 pdf 编辑:程序博客网 时间:2024/04/29 04:13

    <script type="text/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></head><body  onload="time()">    <form id="form1" runat="server">    <div>    <span id="showtime"></span>    </div>    </form></body></html>

0 0