-1

I want to add a timestamp of a data entry creation, example:

myRef.child("uid").setValue(data);
//add timestamp to the same path myRef.child("uid").setValue(<timestamp here>)

What would be the best timestamp, so that it will be independent of any time zone? (For example if a user's phone clock is set to the wrong time)

I did see this article from Firebae docs: Timestamp, but can't figure how to use it.

Doug Stevenson
  • 268,359
  • 30
  • 341
  • 380
TTnote
  • 261
  • 3
  • 13
  • Check also **[this](https://stackoverflow.com/questions/43584244/how-to-save-the-current-date-time-when-i-add-new-value-to-firebase-realtime-data)** out. – Alex Mamo Nov 23 '18 at 09:48

1 Answers1

1

Use the value placeholder firebase.database.ServerValue.TIMESTAMP to update a value with the current clock time on the server at the time of the write, as seen by the server. It's a token value that means nothing on the client but has a special meaning on the server when it's written.

Doug Stevenson
  • 268,359
  • 30
  • 341
  • 380