Ad
Flutter: Firebase FieldValue.serverTimestamp() To DateTime Object
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?
Ad
Answer
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 writeFieldValue.serverTimestamp()
to a document on the server, and observe the value that is written to that document. This value will be a valid timestamp.
Ad
source: stackoverflow.com
Related Questions
- → How can I query Firebase for an equalTo boolean parameter?
- → How can I access nested data in Firebase with React?
- → Firebase simple blog (confused with security rules)
- → Removing item in Firebase with React, re-render returns item undefined
- → AngularJS Unknown Provider Error (Firebase & AngularFire)
- → How do you pass top level component state down to Routes using react-router?
- → "this" is null in firebase query function in reactjs
- → Angular Module Failed to Load
- → Multiple dex files define Lcom/google/android/gms/internal/zzrx;
- → Joining Firebase tables in React
- → How can I make add firepad to my reactjs project?
- → How to use Cloud Functions for Firebase to prerender pages for SEO?
- → React.js component has null state?
Ad