-1

I searched the documentation, Googled, and similar questions, but could not find a clear solution on how to get the server time, I need it to record the time of sending messages to Firestore.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Danil
  • 41
  • 5

1 Answers1

1

How to get the server time?

To be able to read a timestamp, you have to write it first and then read it back. This can be done using FieldValue.serverTimestamp(). In Java, you can simply do it using the solution from the following answer:

But it can simply be translated into Kotlin too.

Please also note that the Firebase server generates the timestamp. This is not generated on the client, but on the server.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193