How do I get the server timestamp in Cloud Functions for Firebase?

前端 未结 7 1227
轮回少年
轮回少年 2020-12-03 00:12

I know you can pull the server timestamp in web, ios, and android - but what about the new Cloud Functions for Firebase? I can\'t figure out how to get the server timestamp

7条回答
  •  没有蜡笔的小新
    2020-12-03 01:04

    If you use the Firebase Admin SDK, here is the correct syntax (Checked 2019-08-27):

    const admin = require('firebase-admin');
    // or
    // import * as admin from 'firebase-admin';
    
    // Using Cloud Firestore
    admin.firestore.FieldValue.serverTimestamp()
    
    // Using Realtime Database
    admin.database.ServerValue.TIMESTAMP
    

提交回复
热议问题