Flutter: Firebase FieldValue.serverTimestamp() to

2019-08-20 21:17发布

I have

FieldValue.serverTimestamp()

I couldn't find a way to convert this timestamp to DateTime object in Flutter. Is there any way to do it? Or any other API call using firebase?

1条回答
对你真心纯属浪费
2楼-- · 2019-08-20 21:58

The FieldValue.serverTimestamp() is not a timestamp, but a so-called sentinel - a marker that gets sent to the server, that the server then recognizes and interprets to write the current timestamp. That means there is no way to convert FieldValue.serverTimestamp() to a timestamp on the client.

What you can do is write FieldValue.serverTimestamp() to a document on the server, and observe the value that is written to that document. This value will be a valid timestamp.

查看更多
登录 后发表回答