D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
jczaplew
Full window
Github gist
Alternate of http://bl.ocks.org/svmatthews/6123346
<!DOCTYPE html> <head> <style> body { text-align:center; } #clock { font-family:arial; font-size:2em; font-weight:bold; color:#555; } </style> </head> <body> <p id="clock"></p> <script> (function() { var end = new Date('08/19/2013 10:1 AM'), sec = 1000, min = sec * 60, hour = min * 60, day = hour * 24, timer; timer = setInterval(function () { var now = new Date(), between = end - now; var days = Math.floor(between / day), hours = Math.floor((between % day) / hour), minutes = Math.floor((between % hour) / min), seconds = Math.floor((between % min) / sec); var dayString = 'days ', hourString = 'hrs ', minString = 'mins ', secString = 'secs '; if (days == 1) { dayString = 'day '; }; if (hours == 1) { hourString = 'hr '; }; if (minutes == 1) { minString = 'min '; }; if (seconds == 1) { secString = 'sec '; }; var clock = days + dayString + hours + hourString + minutes + minString + seconds + secString; document.getElementById("clock").innerHTML = clock; }, 1000); })(); </script> </body> </html>