Results 1 to 8 of 8

Thread: [NEW] Run function once hour after specific time

Threaded View

  1. #1
    Join Date
    Nov 2013

    Post [NEW] Run function once hour after specific time

    I know I made a previous post, on this, but I hasn't been working correctly.

    I want to run a function (weatherForecast_Update) one hour after the given time (forecast_loaded). I am getting the correct time in weatherForecast_Update_time in milliseconds*, but the timeout runs continuously. MomentJS is working perfectly, and if the corrected code could use it, that would be great.

    So I have this code:
    var forecast_loaded = "2013-11-14T19:31:39-06:00";
    moment_now = moment(new Date());
    moment_forecastloaded_add1h = moment(forecast_loaded).add('h', 1);
    var weatherForecast_Update_time = moment_forecastloaded_add1h.valueOf() - moment_now.valueOf();
    if (moment_weatherForecast_Update_time > 0) {
         //setTimeout(weatherForecast_Update(), weatherForecast_Update_time);
    I commented out the setTimeout because it will run too often and freeze up your browser (when testing it). It gives a "stack size exceeded" error.

    Thanks for any help! (great forum )

    *Note: You can easily convert time and other units with Google by typing Xms in min where X is the time, ms is the current unit (in this case milliseconds) and min is the target unit (in this case minutes). The answer will even pop up in the suggestions!
    Last edited by DaAwesomeP; 11-14-2013 at 09:00 PM. Reason: Added Note on conversions with Google

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center