Skip to content

Instantly share code, notes, and snippets.

@tjvantoll
Last active April 19, 2021 19:21
Show Gist options
  • Save tjvantoll/9ab79e7a610b314f6e45e15b04b78b18 to your computer and use it in GitHub Desktop.
Save tjvantoll/9ab79e7a610b314f6e45e15b04b78b18 to your computer and use it in GitHub Desktop.
react-wednesdays.js
// var nextEpisode = new Date(2020, 8, 2, 13);
var nextEpisode = new Date(2020, 8, 1, 10);
var daysSpan = document.querySelector("#countdown-days span");
var hoursSpan = document.querySelector("#countdown-hours span");
var minutesSpan = document.querySelector("#countdown-minutes span");
var secondsSpan = document.querySelector("#countdown-seconds span");
function updateDate() {
var today = new Date();
if (today > nextEpisode) {
document.querySelector("#countdown").style.display = "none";
document.querySelector("#live-now").style-display = "block";
return;
}
var diffSeconds = Math.abs(nextEpisode - today) / 1000;
var diffMinutes = diffSeconds / 60;
var diffHours = diffMinutes / 60;
var diffDays = diffHours / 24;
var days = Math.floor(diffDays);
var hours = Math.floor(diffHours - (days * 24));
var minutes = Math.floor(diffMinutes - (days * 24 * 60) - (hours * 60));
var seconds = 60 - today.getSeconds();
if (seconds === 60) seconds = 0;
daysSpan.innerHTML = ("0" + days).slice(-2);
hoursSpan.innerHTML = ("0" + hours).slice(-2);
minutesSpan.innerHTML = ("0" + minutes).slice(-2);
secondsSpan.innerHTML = ("0" + seconds).slice(-2);
}
updateDate();
setInterval(updateDate, 1000);
@tjvantoll
Copy link
Author

Chicken

@tjvantoll
Copy link
Author

Chicken

@tjvantoll
Copy link
Author

Screen Shot 2020-10-05 at 6 19 00 PM

@tjvantoll
Copy link
Author

browser
package-name
side-by-side-editing
split
whole-workflow
workflow

@tjvantoll
Copy link
Author

react_logo_3

@tjvantoll
Copy link
Author

old-logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment