【问题标题】:Firebase timestamps in ReactReact 中的 Firebase 时间戳
【发布时间】:2020-06-03 23:20:05
【问题描述】:

我正在尝试使用 toDate() 方法显示 Firebase 时间戳,但我不断收到此信息 timestamp error

Error: Objects are not valid as a React child (found: Thu Feb 13 2020 12:00:00 GMT-0800 (Pacific Standard Time)). If you meant to render a collection of children, use an array instead.

但是,当我抛出 debugger 时,我可以使用 note.createdAt.toDate() 通过 console 得到它

如何在网页上很好地展示它?

【问题讨论】:

    标签: reactjs firebase timestamp


    【解决方案1】:

    试试:

    note.createdAt.toDate().toString()
    

    谢谢!

    【讨论】:

    • 请把它变成一个更自信和更好解释的答案。否则,您可能会给人留下提出澄清问题的印象,对此应该使用评论。 IE。这不被视为答案,因此不应写为答案。 meta.stackexchange.com/questions/214173/… 但是,您可以使用edit 和例如“如果您的问题是……解决方案是……,因为……”之类的短语。像这样的“有条件”答案对有类似问题的用户很有帮助。
    猜你喜欢
    • 2019-02-26
    • 1970-01-01
    • 2020-04-08
    • 1970-01-01
    • 1970-01-01
    • 2017-08-16
    • 2020-11-06
    • 2021-11-23
    • 2020-11-04
    相关资源
    最近更新 更多