Created
September 20, 2014 07:05
-
-
Save precious-ming/9e75c00bd347f74eb7a9 to your computer and use it in GitHub Desktop.
网页时间显示
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<div> | |
<span id="nowTime"></span> | |
</div> | |
<script type="text/javascript"> | |
var nowTimeSpan=document.getElementById("nowTime"); | |
function showNowTime(){ | |
var nowDate=new Date(); | |
var month=nowDate.getMonth()+1; | |
if(month<10) | |
month="0"+month; | |
var date=nowDate.getDate(); | |
if(date<10) | |
date="0"+date; | |
var hour=nowDate.getHours(); | |
if(hour<10) | |
hour="0"+hour; | |
var minute=nowDate.getMinutes(); | |
if(minute<10) | |
minute="0"+minute; | |
var second=nowDate.getSeconds(); | |
if(second<10) | |
second="0"+second; | |
nowTimeSpan.innerText=nowDate.getFullYear()+"-"+ | |
month+"-"+date+" "+hour+":"+minute | |
+":"+second; | |
setTimeout(showNowTime,1000); | |
} | |
showNowTime(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment