I have a Cloud Function that resets the date of a document field on Cloud Firestore, but with the hours segment of the Timestamp set to midnight.
This resets at midnight every day from the client side, where the Cloud Function itself is triggered.
The Cloud Function, however, is setting the date to be one hour ahead of the expected date. I.e., if the real date is 29 March 2022 at 00:00:00 UTC+1, the Cloud Function is setting it to be 29 March 2022 at 01:00:00 UTC+1.
I can't use the a serverside timestamp as this doesn't allow any days to be added to it via the Cloud Function, which is necessary for my use case, as I'm sometimes resetting the date for a week ahead on latter parts of the function.
Before the change to UTC + 1 yesterday, the Cloud Function was functioning correctly and was updating the date to the expected date and time (i.e. to midnight).
So far I get the day set to midnight from this:
const today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate());
I then update the document via this:
return ref.doc(doc.id).update({
"Next Date Due": admin.firestore.Timestamp.fromDate(today)
});
