I am trying to make an alarm clock that will play a sound when its done. So, for example, I set the time that the alarm should start at 18:00:00
and the current time is 17:59:00
, so basically the alarm should fire off in 1 min.
I tried doing it in this way.:
var x = '18:00:00';
var t = new Date(x) - new Date();
setTimeout(function(){ alert("Hello"); }, t);
This doesn't work, not sure why. Error is NaN
.