Text(
DateTime.parse(documents[index]['createdAt']
.toDate()
.toString()) ??
'default',
)
I am trying to get date from firestore. I have DateTime.now() stored in createdIn in firestore.
CodePudding user response:
because the format of both is not the same.
- step 1: you can create DateFormat.
- step 2: use 'DateFormat'.parse().
try reading this: https://help.talend.com/r/6K8Ti_j8LkR03kjthAW6fg/atMe2rRCZqDW_Xjxy2Wbqg
CodePudding user response:
If it's a Timestamp field, cast it to Timestamp. If you need that as a DateTime, use a .toDate on that. Don't process it through a string... completely unnecessary.