Hi I have created a countdown clock in JavaScript Now I want to put that clock into a Div tag and format it but unsure how can anyone help?
Code
<!doctype html>
<html>
<head>
<script type="text/javascript">
function cdtd ()
{
var disney = new Date("August 25, 2015 03:00:00");
var now = new Date ();
var timeDiff = disney.getTime() - now.getTime();
var seconds = Math.floor(timeDiff / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
var days = Math.floor(hours / 24);
hours %= 24;
minutes %= 60;
seconds%= 60;
document.getElementById("daysBox").innerHTML = days;
document.getElementById("hoursBox").innerHTML = hours;
document.getElementById("minsBox").innerHTML = minutes;
document.getElementById("secsBox").innerHTML = seconds;
var timer = setTimeout ('cdtd()', 1000);
}
</script></head>
<body>
<div id="daysBox"></div>
<div id="hoursBox"></div>
<div id="minsBox"></div>
<div id="secsBox"></div>
<script type="text/javascript">cdtd(); </script>
</body>
</html>
Thanks Joel
Code
<!doctype html>
<html>
<head>
<script type="text/javascript">
function cdtd ()
{
var disney = new Date("August 25, 2015 03:00:00");
var now = new Date ();
var timeDiff = disney.getTime() - now.getTime();
var seconds = Math.floor(timeDiff / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
var days = Math.floor(hours / 24);
hours %= 24;
minutes %= 60;
seconds%= 60;
document.getElementById("daysBox").innerHTML = days;
document.getElementById("hoursBox").innerHTML = hours;
document.getElementById("minsBox").innerHTML = minutes;
document.getElementById("secsBox").innerHTML = seconds;
var timer = setTimeout ('cdtd()', 1000);
}
</script></head>
<body>
<div id="daysBox"></div>
<div id="hoursBox"></div>
<div id="minsBox"></div>
<div id="secsBox"></div>
<script type="text/javascript">cdtd(); </script>
</body>
</html>
Thanks Joel