2

I am using Node.js for a web app. I would like to fire events at a given time. I know about setTimeout and calculating the offset from the current time. However, this dosen't take into account timezones and such.

My question is, is there an npm module that can make this process of firing events (or dealing with the clock/time in general) easier?

So for example, I could do: lib.fireEvent("1:00pm PST", event) which would fire the event every day at 1pm.

Brad
  • 159,648
  • 54
  • 349
  • 530
Alexis
  • 23,545
  • 19
  • 104
  • 143

2 Answers2

1

What you should do is have a timeout every second or so that checks the current time on the clock. That will be much more accurate.

Brad
  • 159,648
  • 54
  • 349
  • 530
0

I'm trying out this one: https://github.com/ncb000gt/node-cron Seems to working fine, and can be set to execute at a specific time.

Morten
  • 4,507
  • 7
  • 29
  • 31