0

I need to schedule Firebase Cloud Function invocation, but with a given timestamp, not like Cron.

Does anyone know how to implement something like this?

Even with a "regular" functions, is it possible?

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123

1 Answers1

0

There's nothing built in to Cloud Functions for triggering code at a specific date. But you can easily build it yourself on top of a periodically triggered function, by adding a simple condition in the function.

For example: if you have a function that gets triggered every night at midnight, you can add an extra check in your code to see if "today is the day":

exports.accountcleanup = functions.https.onRequest((req, res) => {
  var now = new Date();
  if (now.getFullYear() == 2017 && 
      now.getMonth() === 11 && // Months are 0 based, so 11 is December
      now.getDate() ===  28) {
    ...
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807