Jump to content
  • Advertisement
Sign in to follow this  
Telastyn

[JavaScript] Execute function at given time

This topic is 2559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
b = new Date("UTC time");
a = new Date();

delta = b.getTime() - a.getTime();

setTimeout(foo, delta);


Syntax might be a bit off.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!