javascriptnode.jscrontimezonenode-schedule

Running a backround service by applying server Timezone in javascript using node-schedule (Node.js.)


Hello stack overflow community,

I am an absolute beginner with regard to how servers configuration works. Currently, I have an app to be scheduled at a specific time, for every 5 minutes. (8:00 am - 10:00PM Malaysia Time, (GMT+8)). But my server is using Eastern Daylight Time, (EDT).

So how do I write it in my program so it will run on the 8-9 PM Malaysia time.

Below is my current code.

var schedule = require("node-schedule");

schedule.scheduleJob("*/5 8-22 * * *", function () {
//Some code to get data
  });

Thanks for any helps in advance


Solution

  • Your server is Eastern Daylight Time, (EDT) equal to GMT-4 and you want to run your code at 8:00 GMT+8

    Then it would be from 8 P.M (20:00) the day BEFORE to 10 A.M CURRENT DAY in EDT time.

    For this case, maybe you would like to see this cronjob over midnight. Good luck.