How I will do that: When seconds come 31 (example 11:57 31sec.) do somthing, every minute. Using Javasript.
Thanks in advance.
How I will do that: When seconds come 31 (example 11:57 31sec.) do somthing, every minute. Using Javasript.
Thanks in advance.
Read the current time, calculate the number of seconds until the next time the seconds is ':31' then use setTimeout with the appropriate delay. You could use something like this:
var atSeconds = 31;
var secondsLeft = atSeconds - new Date().getSeconds();
if (secondsLeft <= 0) secondsLeft += 60;
setTimeout(foo, secondsLeft * 1000);
Remember to call it again in the function foo
so that it repeats.
Something like this will probably be as close as you can get.
function initializeInterval() {
while (new Date().getSeconds() < 30);
setInterval(doWork, 60000);
}
function doWork() {
}