How to get firestore timestamp

后端 未结 4 2179
孤城傲影
孤城傲影 2021-02-07 19:18

I\'m trying to get the timestamp of a document that I created in firestore, but what I get is this:

myService.ts

getDomiciliari         


        
4条回答
  •  不思量自难忘°
    2021-02-07 19:46

    If you want the current Date as a timestamp you can use the following

    For Firebase Functions

    import admin = require('firebase-admin');
    
    const todayAsTimestamp = admin.firestore.Timestamp.now()
    

    For local projects

    import { Timestamp } from '@google-cloud/firestore';
    
    const myTimestampAsDate = Timestamp.now()
    

提交回复
热议问题