JSFiddle - React, Tailwind, and code Playground
HTML
<div class="time"></div>
JavaScript
function time(el) {
var today = new Date();
var hour = today.getHours();
var minute = today.getMinutes();
var second = today.getSeconds();
var line = "–";
var twoPoints;
el.innerHTML = hour+':'+minute+':'+second;
if (second % 2 == 0){
el.style.color="red";
} else {
el.style.color="green";
}
}
var el = document.querySelector('.time');
setInterval(function(){
time(el);
})