Home > Web Front-end > JS Tutorial > body text

How to display time

一个新手
Release: 2017-10-11 09:42:26
Original
1381 people have browsed it

<!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>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!