<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<style>
#clock { overflow: hidden; }
#clock.x .U_003A { color: #333399; }
#clock .date { clear: left; }
#clock .U_003A {
color: #9c9c9c;
float: left;
}
#clock .timer .digit:nth-child(4) {
background-color: #228B22;
color: #FFFFFF;
}
#clock .timer .digit:nth-child(7) {
background-color: #FF00FF;
color: #FFFF00;
}
#clock .timer .digit {
border: 1px solid #0000FF;
float: left;
width: 16px;
text-align: center;
margin: 0 1.5px;
}
</style>
<span id="clock"></span>
<script>
function clock() {
setTimeout(clock, 500);
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 months = ["января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря"];
var dayNames = ["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"];
function numberWrapInDiv(num) {
num = String(num);
if(num.length === 1) num = "0" + num;
for (var i = 0, html = ""; i < num.length; i++) html += "<div class=\"digit\">" + num.charAt(i) + "</div>";
return html;
}
hour = numberWrapInDiv(hour), minute = numberWrapInDiv(minute), sec = numberWrapInDiv(sec);
document.getElementById("clock").innerHTML = "<div class='timer'>"+hour+" <div class='U_003A'>:</div> "+minute+" <div class='U_003A'>:</div> "+sec+"</div><div class='date'>"+dayNames[weekday]+"<br/>"+(day<10?"0":"")+day+" "+months[month]+" "+year+" г.</div>";
document.getElementById("clock").className.toggle("x");
}
clock();
</script>
</body>
</html>
|