The color of time

Turn the current time into a hex color

by Dan Shahin

HTML

<div id="t"></div>
<div id="h"></div>

CSS

body{
    padding-top:20vh;
    text-align:center;
}
div{
 color: white;
 font-size: 15vw;
}

JavaScript

dotime();
function dotime(){
	
	$("body").css({"transition": "all 0.8s", "-webkit-transition": "all 0.8s"});
	
	var d = new Date();
	var hours = d.getHours();
	var mins = d.getMinutes();
	var secs = d.getSeconds();
	
    //zero pad the single digit numbers
	if (hours < 10){hours = "0" + hours};
	if (mins < 10){mins = "0" + mins};
	if (secs < 10){secs = "0" + secs};

	var hex = "#" + hours + mins + secs;
    var time = hours + ':' + mins + ':' + secs;
	
	$("#t").html(time);
	$("#h").html(hex);
	
	document.body.style.background = hex;
	
	setTimeout(function(){ dotime();}, 1000);
}