Anyone knows how to persist UTC Timestamp in Firestore?
In my Angular
app, if I convert today's date to a Timestamp like the following and I end up with a UTC+2
(it's summer time here right now in Switzerland) date in the Firestore database
import {firebase} from '@firebase/app';
import '@firebase/firestore';
const myTimestamp = firebase.firestore.Timestamp.fromDate(new Date());
If for example I try to convert a date from the winter time, I end up with UTC+1
Timestamp in the database
const myTimestamp = firebase.firestore.Timestamp.fromDate(new Date(2019, 0, 1));
If I would use now()
I end up with UTC+2
dates too
const now: firebase.firestore.Timestamp = firebase.firestore.Timestamp.now();
I don't do anything particular when I persist the data:
const now: firebase.firestore.Timestamp = firebase.firestore.Timestamp.now();
const myTimestamp = firebase.firestore.Timestamp.fromDate(new Date());
const myData = {
created_at: now,
another_value: myTimestamp
};
await this.collection.add(myData);
Any idea how is it possible to create valid UTC
Timestamp for Firestore?