0

greetings, the question is how you can get the current date from the firebase cloud server.

I have a DownCountTimer

And I need to get the date from the server, in order to achieve that wherever you go (Japan, Chile, Arabia, etc.) the DownCountTimer has the same time and ends for everyone equally, the only thing that occurred to me is to use the fixed date of the server.

If I use Timestamp.now ()

It seems that it is the date from the device, because if I change the time zone of the device, or the time, then the counter changes. And what I need is for you to change the date phone, or have a different time zone, the counter is always the same for everyone, I hope I have explained myself, I hope they have some solution, and help me with this problem, in advance Thank you

aAaDesigner
  • 21
  • 1
  • 5

1 Answers1

0

Server Timestamps

The Firebase Realtime Database servers provide a mechanism to insert timestamps generated on the server as data. This feature, combined with onDisconnect, provides an easy way to reliably make note of the time at which a Realtime Database client disconnected:

var userLastOnlineRef = firebase.database().ref("users/joe/lastOnline");

userLastOnlineRef.onDisconnect().set(firebase.database.ServerValue.TIMESTAMP);

Anushka Pubudu
  • 389
  • 3
  • 10