<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<style>
span.U_003A { color: #9c9c9c; }
#clock.x span.U_003A { color: #333399; }
#clock .timer{
display: flex;
}
#clock .timer div:nth-child(4){
background-color: #228B22;
color: #FFFFFF;
}
#clock .timer div:nth-child(7){
background-color: #FF00FF;
color: #FFFF00;
}
#clock .timer div{
border: 1px solid #0000FF;
display: inline-block;
width: 16px;
text-align: center;
margin: 0 1.5px;
}
</style>
<span id="clock"></span>
<script type="text/javascript">
function clock() {
var date = new Date();
var hour=date.getHours();
var minute=date.getMinutes();
var sec=date.getSeconds();
var day=date.getDate();
var month=date.getMonth();
var year=date.getFullYear();
var weekday=date.getDay();
var monthes=new Array ("января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря");
var dayNames = new Array("Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота");
function numberWrapInDiv(num)
{
return [...num.toString().padStart(2, "0")].map(num => `<div>${num}</div>`).join("")
}
[hour, minute, sec, day, year] = [hour, minute, sec, day, year].map(numberWrapInDiv)
document.getElementById("clock").innerHTML = "<div class='timer'>"+hour+" <span class='U_003A'>:</span> "+minute+" <span class='U_003A'>:</span> "+sec+"</div>"
+dayNames[weekday]+"<br/>"
+"<div class='timer'>"+day+" "+monthes[month]+" "+year+"<div>г.</div>"+"</div>";
document.getElementById("clock").classList.toggle("x");
window.setTimeout("clock()",500);
}
clock();
</script>
</body>
</html>
|