I have a relatively simple problem at first glance that I suspect has a really slick solution that I don't know about, and don't particularly have the time to hunt through google'd libraries for:
In javascript, I need to trigger a specified anonymous function at a given UTC time. What's a good way to get that done?
Though I'm familiar with a number of the concepts, I don't have a lot of experience with the language or its idioms/libraries. Thanks in advance.
[JavaScript] Execute function at given time
Just to throw an idea down, you could probably use setTimeout which will execute your function after a specified delay. It's then just a matter of calculating the 'delay' between now till your desired time in UTC.
Where exactly is this javascript executing?
In a programatically generated webpage on the local filesystem being browsed to by the WebBrowser control in .NET, set to force IE9 compatibility mode.
b = new Date("UTC time");
a = new Date();
delta = b.getTime() - a.getTime();
setTimeout(foo, delta);
Syntax might be a bit off.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement