Отметка времени от Firebase до даты String - PullRequest
0 голосов
/ 03 августа 2020

У меня есть модель Timestamp и я получил Timestamp от Firebase. print(user.endDate.toDate()); = flutter: 2020-08-05 00:00:01.000 Новый вопрос, но я борюсь с тем, что я должен использовать здесь: Text(?), чтобы получить дату

Ответы [ 2 ]

0 голосов
/ 03 августа 2020

используйте класс времени

пример:

//before we show the date we need to parse it then show it in a format Month 2 , 2020

     Container(
    child: Text(new DateFormat.yMMMd().format(DateTime.parse(productInfo["createdAt"]))),
               ),

// this is your time => productInfo["createdAt"]

DateTime класс

0 голосов
/ 03 августа 2020
Timestamp firestoreTimestamp = data['timestamp'];
DateTime dateTime = firestoreTimestamp.toDate();

Text(dateTime.toString());
...