I have stored in Firestore documents with createdAt field containing date and timezone of the user. For example(December 22, 2019 at 9:21:42 PM UTC-3)
Then, I have a cloud functions where I want to retrieve all of Today documents. The problem is that the cloud function doesn't know the Timezone, and that gets messy when retrieveng documents of diferent timezones.
const now: Date = new Date();
const docQuery = await db
.collection('users')
.where('createdAt', '>', new Date(now.getFullYear(), now.getMonth(), now.getDate()))
.where('createdAt', '<', new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59))
.get();
The now
date is in UTC-0 and if I have a document from the day before at 22:00 UTC-3, the query retrieves it, but technically it is not a Today document.
Any idea on how to tackle this issue?