How to print Firestore timestamp as formatted date and time

前端 未结 13 1610
野性不改
野性不改 2021-02-07 11:07

My timestamp returns Timestamp(seconds=1560523991, nanoseconds=286000000) in a Flutter Firestore snapshot.

I want to print it as properly formatted date and

13条回答
  •  囚心锁ツ
    2021-02-07 12:02

    Using cloud firestore, Here's my what worked for me:

    Text(snapshot.data["YouKey"].toDate().toString().substring(0,16))
    

    subString is optionnal, I've added it because I had the clock time with many number after the minute (like 12:00 00:00:00)

提交回复
热议问题