0

How can i get the Current time from firestore Database . Even if the system time is changed or incorrect in User's phone . I know how to add the timestamp field in firestore (models class)

private @ServerTimestamp
   Date timestamp;"

But how can i get the current time from firestore as vice versa have tried this

Log.d(TAG, "onSuccess: TimerFIres:" + FieldValue.serverTimestamp());

But my output was :

onSuccess: TimerFIres:com.google.firebase.firestore.FieldValue$ServerTimestampFieldValue@41f2cd1

Can anyone help me with this! thanks.

Frank van Puffelen
  • 499,950
  • 69
  • 739
  • 734
Shiva s
  • 198
  • 2
  • 9
  • The Firebase Realtime Database and Cloud Firestore are two separate databases. Please only mark your question with the relevant tag, not with both. – Frank van Puffelen Jul 11 '20 at 14:34
  • The `` object is a so-called sentinel, not a real timestamp. It won't get a value until it's written to the database. See https://stackoverflow.com/search?q=%5Bgoogle-cloud-firestore%5D%5Bandroid%5D+get+current+time. For example, this answer looks promising: https://stackoverflow.com/a/61162196, as does this one: https://stackoverflow.com/a/48475027 – Frank van Puffelen Jul 11 '20 at 14:41

0 Answers0