Date vs Timestamp for Firebase

后端 未结 1 913
忘了有多久
忘了有多久 2020-12-10 14:52

What would you recommend to store dates using Firebase between a datetime and a timestamp, and why?

相关标签:
1条回答
  • 2020-12-10 15:31

    Use a timestamp as this is locale-agnostic and does not require formatting and parsing agreements between clients. It's also a bit shorter.

    Furthermore, utilize Firebase.ServerValue.TIMESTAMP, rather than trusting the clients to have their clocks set correctly. If, for example, a client's clock is off by 5 minutes and you utilize the client timestamps in a chat conversation, then rendering back the messages, the time shown would appear to be 5 minutes in the future for other users.

    0 讨论(0)
提交回复
热议问题