JSFiddle - React, Tailwind, and code Playground
by bluey
HTML
<span id="endDate">....Initializing....</span>
<br/>
<span id="spanDate">....Initializing....</span>
<br />
<span id="spanDate2">....Initializing....</span>
<br />
<span id="spanDate3">....Initializing....</span>
<br />
<img src='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQsqGjyuWDeqiX3L6gdeXP3w3Ctk5_dQfkeALkC8c_nZVWiuZgBPg' width='500px';/>
JavaScript
/*
every second,
create random char from regex,
write char "different of previous one" to each class='num'AS-span.child of timer.
*/
function stopclock(){
if(timerRunning){
clearTimeout(timerID);
timerRunning = false;
}
}
function startclock(){
stopclock();
showtime();
}
function showtime(){
var now = new Date();
var end = new Date("2015/07/30 21:59:00");
var thedifDate = end - now;
var difDate = new Date(thedifDate);
var year = now.getFullYear();
var month = now.getMonth();
var days = now.getDay();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var mseconds = now.getMilliseconds();
var eyear = end.getFullYear();
var emonth = end.getMonth();
var edays = end.getDay();
var ehours = end.getHours();
var eminutes = end.getMinutes();
var eseconds = end.getSeconds();
var emseconds = end.getMilliseconds();
var nYear = eyear - year;
var nMonth = month - emonth;
var nDays = edays - days;
var nHours = hours - ehours;
var nMinutes = eminutes - minutes;
var nSeconds = seconds - eseconds;
var nMseconds = mseconds - emseconds;
var timestring = "";
timestring += ((year < 10) ? "" : "") + year;
timestring += ((month < 10) ? ":0" : ":") + month;
timestring += ((days < 10) ? ":0" : ":") + days;
timestring += ((hours < 10) ? ":0" : ":") + hours;
timestring += ((minutes < 10) ? ":0" : ":") + minutes;
timestring += ((seconds < 10) ? ":0" : ":") + seconds;
var endstring = "";
endstring += ((eyear < 10) ? "" : "") + eyear;
endstring += ((emonth < 10) ? ":0" : ":") + emonth;
endstring += ((edays < 10) ? ":0" : ":") + edays;
endstring += ((ehours < 10) ? ":0" : ":") + ehours;
endstring += ((eminutes < 10) ? ":0" : ":") + eminutes;
endstring += ((eseconds < 10) ? ":0" : ":") + eseconds;
var...