Alexis
Alexis

Reputation: 25163

Cron-like library for Node.js to fire events at specific times

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.

Upvotes: 2

Views: 2215

Answers (2)

Morten
Morten

Reputation: 4607

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.

Upvotes: 0

Brad
Brad

Reputation: 163301

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.

Upvotes: 1

Related Questions