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?
2
Answers
Per the API reference, the first parameter is either a schedule or a
scheduler.ScheduleOptions
object. FYI: This options object can also contain options inGlobalOptions
(secrets
,region
, etc.).To specify a time zone, you would use:
Considering the documentation it doesn’t seem possible to add the timezone unless you can ssh into the firebase server and run custom commands to change the computer local timezone.