Home  >  Article  >  Web Front-end  >  How to display time

How to display time

一个新手
一个新手Original
2017-10-11 09:42:261399browse

<!DOCTYPE html>
<html> 
    <head> 
        <meta charset="utf-8"> 
            <title>获取当前时间</title> 
            <script type="text/javascript"> function getDate() {
                var currentTime=new Date().getHours()+":"+new Date().getMinutes()+":"+new Date().getSeconds();
                var span=document.getElementById("timeSpan");
                span.innerHTML=currentTime;
                window.setTimeout(getDate,1000);            }
            </script> 
            </head> 
            body> 
            <input type="button" id="" value="获取当前时间" onclick="getDate()"/> 
        <span id="timeSpan"></span> 
    </body>
</html>

The above is the detailed content of How to display time. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn