Y
Y
ywitodenasuby2019-09-17 23:09:26
Android
ywitodenasuby, 2019-09-17 23:09:26

How to get server time in Google Firebase?

How to get server time in Google Firebase?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Dudarev, 2019-09-18
@Anoubis1981

If I understand the question correctly - do you need to save server time?
For firestore:

const admin = require('firebase-admin');
admin.initializeApp();
const db = admin.firestore();
const FieldValue = require('firebase-admin').firestore.FieldValue;

Next, save the time stamp like this:
const timestamp = db
  .collection('data')
  .doc('base')
  .set({ timestamp: FieldValue.serverTimestamp() });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question