任何人都知道如何在 Firestore 中保留 UTC 时间戳?
在我的Angular
应用程序中,如果我将今天的日期转换为如下所示的时间戳,并且我最终会UTC+2
在 Firestore 数据库中得到一个(现在是瑞士的夏令时)日期
import {firebase} from '@firebase/app';
import '@firebase/firestore';
const myTimestamp = firebase.firestore.Timestamp.fromDate(new Date());
例如,如果我尝试从冬季时间转换日期,我最终会UTC+1
在数据库中使用Timestamp
const myTimestamp = firebase.firestore.Timestamp.fromDate(new Date(2019, 0, 1));
如果我使用,我也会now()
得到UTC+2
日期
const now: firebase.firestore.Timestamp = firebase.firestore.Timestamp.now();
当我保留数据时,我没有做任何特别的事情:
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);
知道如何UTC
为 Firestore创建有效的时间戳吗?