【发布时间】:2020-03-03 12:45:54
【问题描述】:
我正在以 DateTime(2020, 02, 29, 9) 的身份从我的 Flutter 应用程序将时间戳上传到 Firestore 文档
时间戳在 Firestore 中存储为 February 29, 2020 at 9:00:00 AM UTC-6
使用 document['timestamp'].toDate().hour 从颤振应用程序中检索时间戳会按预期返回“9”。
在云函数中获取此数据时会出现此问题。 snap.timestamp.toDate() 将日期对象返回为Sat Feb 29 2020 03:00:00 GMT+0000 (UTC),不考虑时区偏移。
如何检索与存储在 Firestore 中的时间相同的时间,而不是获取 UTC 时间。
【问题讨论】:
标签: firebase datetime google-cloud-firestore google-cloud-functions