首页 > 解决方案 > Cloud Firestore 中的日期和时间格式

问题描述

我将 Flutter 用于我的移动应用程序。它以这种格式将日期存储在云 Firestore 中。

February 14, 2020 at 12:00:00 AM UTC+5

但是当我从 Cloud Functions 保存日期时,它会存储为 Map

{
_nanoseconds: 0,
_seconds: 1582743600
}

我希望云函数根据 Flutter 的格式存储日期。

我怎样才能做到这一点?

标签: typescriptfirebasegoogle-cloud-firestoretimestampgoogle-cloud-functions

解决方案


它将其存储为firebase.firestore.Timestamp( doc )。

Timestamp您可以使用导入

import { Timestamp } from "@google-cloud/firestore";

推荐阅读