serverTimestamp constant
FieldValue
const serverTimestamp
Returns a sentinel used with set(), create() or update() to include a server-generated timestamp in the written data.
final documentRef = firestore.doc('col/doc');
documentRef.set({
'time': Firestore.FieldValue.serverTimestamp()
}).then(() {
return documentRef.get();
}).then((doc) {
print('Server time set to ${doc.get('time')}');
});
Implementation
static const FieldValue serverTimestamp =
_ServerTimestampTransform.serverTimestampSentinel;