How to print Firestore timestamp as formatted date and time

前端 未结 13 1576
野性不改
野性不改 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:13

    First visit here for intl package, then paste the package into your pubspec.yaml, run pub get (the usual way of updating pubspec).Import the package into your dart file and try out the below method.

    String timestamp;
    
    DateTime now = DateTime.now();
    String formatDate =
        DateFormat('yyyy-MM-dd – kk:mm').format(now);
    timestamp = formatDate;
    
    0 讨论(0)
提交回复
热议问题