JSFiddle - React, Tailwind, and code Playground
by Pratik Galoria
JavaScript
const start = () => {
const date = new Date();
const currentSeconds = (date.getHours() * 60 + date.getMinutes()) * 60 * 1000;
const endTimeSeconds = (18 * 60 + 5) * 60 * 1000;
const remainingSeconds = endTimeSeconds - currentSeconds;
if (remainingSeconds > 0) {
console.log('streaming started.');
const streamer = setInterval(() => {
console.log(currentSeconds, endTimeSeconds, remainingSeconds);
}, 5000);
setTimeout(() => {
console.log('streaming ended.');
clearInterval(streamer);
}, remainingSeconds);
}
};
start();