none
如何在网页上显示日期时间啊 RRS feed

答案

  • 你好,

      如果你想使用javascript或jquery动态显示时间,你能尝试下面这样的方法:

    <html>
        <head>
            <script type="text/javascript">
                <!--
                function updateTime() {
                var currentTime = new Date();
                var hours = currentTime.getHours();
                var minutes = currentTime.getMinutes();
                var seconds = currentTime.getSeconds();
                if (minutes < 10){
                minutes = "0" + minutes;
                }
                if (seconds < 10){
                seconds = "0" + seconds;
                }
                var v = hours + ":" + minutes + ":" + seconds + " ";
                if(hours > 11){
                v+="PM";
                } else {
                v+="AM"
                }
                setTimeout("updateTime()",1000);
                document.getElementById('time').innerHTML=v;
                }
                updateTime();
                //-->
            </script>
        </head>
        <body>
            <h4>Current Time: <span id="time" /></h4>
        </body>
    </html>

    当然,你也能通过使用Timer计时器和Label等服务器端控件实现相似的功能,需要写后台代码。


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年4月15日 1:29
    版主