Flutter如何转换时间戳日期时间
Flutter how to convert timestamp date time
我正在从商店获取日期和时间。在数据库中它看起来像这样
需要知道如何将其显示为 DD/MM/YY
我正在尝试这样做
String timeString = snapshot.data[index]['lastupdate'].toString();
DateTime date = DateTime.parse(timeString);
print(DateFormat('yyyy-MM-dd').format(date));
显示无效日期格式错误
像这样尝试你的最后更新日期没有转换为 Date 这就是它显示错误的原因
DateTime date = DateTime.parse(snapshot.data[index]['lastupdate'].toDate().toString());
print(DateFormat('dd-MMM-yyy').format(date));
我正在从商店获取日期和时间。在数据库中它看起来像这样
需要知道如何将其显示为 DD/MM/YY
我正在尝试这样做
String timeString = snapshot.data[index]['lastupdate'].toString();
DateTime date = DateTime.parse(timeString);
print(DateFormat('yyyy-MM-dd').format(date));
显示无效日期格式错误
像这样尝试你的最后更新日期没有转换为 Date 这就是它显示错误的原因
DateTime date = DateTime.parse(snapshot.data[index]['lastupdate'].toDate().toString());
print(DateFormat('dd-MMM-yyy').format(date));