-1

I want to run a function every 10th minute in an hour. So for 10AM, the events will fire exactly at:

10:00
10:10
10:20
10:30
10:40
10:50

I'm aware of setTimeout and setInterval, however:
1. They're never exact. They're sometimes early, or delayed. They also get effected by being out of focus.
2. I'm not sure how to make a system (as I mentioned above) that will work with timeouts or intervals. 3. Looking for the right way to do this.

I'm not looking for a timer, but a scheduler.

Any ideas are appreciated.

8
  • They're never exact - how precise are we talking? Jun 15, 2015 at 23:20
  • alarm precise. I don't want things to get delayed even if they run for a week.
    – Mia
    Jun 15, 2015 at 23:21
  • 1
    Is ~1 second off at max acceptable? Jun 15, 2015 at 23:22
  • 1
    @Zettam where do you run this? client/server side?
    – vitr
    Jun 15, 2015 at 23:22
  • @vitr clientside, web page.
    – Mia
    Jun 15, 2015 at 23:24

1 Answer 1

0

I personally would use NodeJS or other sync solution. Easy way: http://www.webdesignerdepot.com/2013/06/how-to-build-a-realtime-jquery-plugin/

4
  • How would yo do that clientside?
    – Mia
    Jun 15, 2015 at 23:26
  • I won't answer this, because this may get you in trouble. One of the coders rules - never trust clientside. I personally don't trust setInterval or setTimeout. What the sense? If clients browser did lag, then that's it - delay.
    – user985818
    Jun 15, 2015 at 23:29
  • Well this is for a static webpage, no server side. In other words "trust" is not an issue. I just want this to work properly.
    – Mia
    Jun 15, 2015 at 23:31
  • This is most accurate solution, I guess. github.com/mrchimp/tock Because it has self-correcting system inside. So, I would try to adapt this to your needs.
    – user985818
    Jun 15, 2015 at 23:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.