代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
*{
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<p id="p"></p>
<script>
setInterval(time,1000);
function time() {
var p = document.getElementById("p");
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth()+1;
var day = now.getDay();
var hour = now.getHours();
var min = now.getMinutes();
var sec = now.getSeconds();
var str = year +":"+month+":"+day+":"+hour+":"+min+":"+sec;
p.innerHTML = str;
}
</script>
</body>
</html>