<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<script>
setInterval(function () {
time = new Date();
year = time.getFullYear();
month = time.getMonth() + 1;
day = time.getDate();
hour = time.getHours();
minute = time.getMinutes();
second = time.getSeconds();
str = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
document.getElementsByClassName('show')[0].innerHTML = str;
}, 1000);
alert(str);
</script>
<style>
.show {
background-color: rgba(0, 0, 0, .5);
color: aliceblue;
text-align: center;
border: solid;
border-radius: 8px;
}
</style>
</head>
<body>
<p class="show"></p>
</body>
</html>