In Firebase Cloud Functions v1, configuring the time zone for scheduled functions could be done in the function’s signature.
exports.v1ScheduledFunction = functions.pubsub.schedule("every day 00:00")
.timeZone("Etc/GMT+12")
.onRun(async (context) => {
...
});
However, with the syntax changes in v2, this changes.
exports.v2ScheduledFunction = onSchedule("every day 00:00", async (event) => {
...
});
The documentation says that v2 can take Unix Crontab and App Engine syntax for the string schedule. However, I don’t think you can specify time zone in either Unix Crontab or App Engine syntax. Is there a way to specify time zone for scheduled functions in v2 in code? If not, how can it be done?
>Solution :
Per the API reference, the first parameter is either a schedule or a scheduler.ScheduleOptions object. FYI: This options object can also contain options in GlobalOptions (secrets, region, etc.).
To specify a time zone, you would use:
exports.v2ScheduledFunction = onSchedule(
{
schedule: "every day 00:00",
timeZone: "Etc/GMT+12"
},
async (event) => {
// your function code
}
)