DateTime.parse 给出错误的日期
DateTime.parse giving Wrong Date
我正在以字符串格式从 Firestore 获取日期
然后我在 DateTime 中投射
但是 DateTime.parse() 给我错误的日期
实际日期是 (yyyy-MM-dd HH:mm) = 2022-01-29 15:23
输出为 (yyyy-MM-dd HH:mm) = 2024-05-01 15:23
你能解释一下为什么要给
使用 DateFormat.parse() 解析它,像这样:
dependencies:
intl: ^0.17.0
然后:
import 'package:intl/intl.dart';
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
DateTime dateTime = dateFormat.parse("2019-07-19 8:40:23"); // <-- your string inside
我正在以字符串格式从 Firestore 获取日期 然后我在 DateTime 中投射 但是 DateTime.parse() 给我错误的日期
实际日期是 (yyyy-MM-dd HH:mm) = 2022-01-29 15:23 输出为 (yyyy-MM-dd HH:mm) = 2024-05-01 15:23
你能解释一下为什么要给
使用 DateFormat.parse() 解析它,像这样:
dependencies:
intl: ^0.17.0
然后:
import 'package:intl/intl.dart';
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
DateTime dateTime = dateFormat.parse("2019-07-19 8:40:23"); // <-- your string inside