As far as I know (and I know relatively little), there is no native event that is emitted when, for example, the second hand of seconds. The best that I came up with repeatedly checks the Date object (for example, every 333 ms, a shorter interval leads to higher accuracy, but also more resource intensive). Anyway, if I use the same Date object again and again, the time will not be updated, but
Date.prototype.getSeconds()
logs are "NaN", although typeof is a "number".
function clock(interval) { var d = new Date(); var secondsOld = d.getSeconds(); d = null; setInterval(function() { var d = new Date(); var secondsNew = d.getSeconds(); if ( secondsNew !== secondsOld ) { secondsOld = secondsNew;
source share