简体   繁体   中英

How to get server time firebase Firestore kotlin?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM