I know you can pull the server timestamp in web, ios, and android - but what about the new Cloud Functions for Firebase? I can\'t figure out how to get the server timestamp
you want to set document field to server timestamp
Example can be
user {
email: "example.com",
lastUpdated: admin.firestore.FieldValue.serverTimestamp(),
}
Note serverTimestamp returns a non-null Object and is a placeholder value for auto-populating the current timestamp.
It doesn't contain the actual timestamp. The database will replace this placeholder when it will execute the command
*Returns a sentinel used with set(), create() or update() to include a server-generated timestamp in the written data.
@return The FieldValue sentinel for use in a call to set(), create() or update().*
you want use server time stamp for your functions logic
if (currentTime == 6pm) // TODO: send push notifications
else // TODO: do nothing
for that you might want to do something like
admin.firestore.Timestamp.now() or admin.firestore.Timestamp.fromDate(new Date())good reads: https://bigcodenerd.org/firebase-server-timestamp-cloud-functions/