【问题标题】:how to store date in the firebase with type 'timestamp' instead of 'map' from reactjs如何使用'timestamp'类型而不是来自reactjs的'map'类型在firebase中存储日期
【发布时间】:2021-09-18 05:37:03
【问题描述】:

从反应应用程序中,我从日期选择器获取日期。我正在尝试保存它 火力基地。它在数据库中正确保存,但不是 TYPE 作为“时间戳”,而是像“地图”一样保存。我正在向我们创建的 firebase 函数发送数据。通过该功能,我们将数据保存到集合中。请有任何建议。

const d = new Date("27-5-2021")
firebase.firestore.Timestamp.fromDate(d)
(OR)
firebase.firestore.Timestamp.fromMillis(d.getTime())

【问题讨论】:

标签: node.js reactjs firebase


【解决方案1】:

我认为您需要做这样的事情才能将其保存为 firebase 上的时间戳。

firebase.firestore.Timestamp.fromDate(date).toDate());

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-18
    • 2021-10-17
    • 2015-07-04
    • 2023-03-24
    • 2017-12-18
    • 2011-06-20
    • 1970-01-01
    • 2013-06-24
    相关资源
    最近更新 更多