Flutter×Firebase Timestampの日時情報を表示
Flutter×Firebase Timestampの時間表示
流れとしては、
①Firestoreのtimestampで時間取得
②そのtimestampをdatetimeに変更
③テキストとして表示
①以下のコードでtimestampというフィールド名で時間取得
Firestore.instance.collection('コレクション名').add({'timestamp': FieldValue.serverTimestamp()});
②datetimeに変更
final timeStamp = snapshot.data.documents[index]['timestamp'];
final d = timeStamp.toDate();
③テキストとして表示
Text(d.year.toString() + '/' + d.month.toString() + '/' + d.day.toString() + ':' + d.hour.toString() + ':' + d.minute.toString + ':' + d.second.toString())
Author And Source
この問題について(Flutter×Firebase Timestampの日時情報を表示), 我々は、より多くの情報をここで見つけました https://qiita.com/hattori2/items/25468917b3ae8634dce1著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .