【问题标题】:create a Timestamp object in angularfire app在 angularfire 应用程序中创建时间戳对象
【发布时间】:2018-12-29 21:49:50
【问题描述】:

第一次尝试

import { Timestamp } from '@firebase/firestore-types';

然后如何创建 Timestamp 对象?

var now: Timestamp = ???

var now: Timestamp = Timestamp.now() //Module not found: Error: Can't resolve '@firebase/firestore-types'

【问题讨论】:

    标签: angular firebase timestamp angularfire2


    【解决方案1】:
    import { Timestamp } from '@firebase/firestore-types';
    

    这里的Timestamp只是一个类型,如果你想得到当前时间就用

    var now = new Date(;
    

    【讨论】:

      【解决方案2】:

      JS Date 对象会在 Firestore/firebase 中保存为时间戳:

      ref.update({ updatedAt: new Date() })
      // results in timestamp in Firestore
      

      【讨论】:

        猜你喜欢
        • 2011-07-16
        • 2011-04-29
        • 1970-01-01
        • 2014-03-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-12
        • 1970-01-01
        相关资源
        最近更新 更多