Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Datetime 格式异常:日期格式2018-08-1无效_Datetime_Flutter_Dart - Fatal编程技术网

Datetime 格式异常:日期格式2018-08-1无效

Datetime 格式异常:日期格式2018-08-1无效,datetime,flutter,dart,Datetime,Flutter,Dart,如果我在DartPad中写,print(DateTime.parse(“2012-12-12”)它可以工作。那么,当我执行以下操作时(它报告“无效日期格式”),为什么它不起作用呢 for(int i=1;i将此添加到包的pubspec.yaml文件中: 依赖项: 国际:^0.16.0 更多信息,请参见:因为DateTime.parse需要4位数字表示年份,2位数字表示月份,2位数字表示日期。在For循环中,我以1开头,这是一个低于9的数字,因此由于它是一个单位数字,解析函数没有收到预期的输入。

如果我在DartPad中写,
print(DateTime.parse(“2012-12-12”)它可以工作。那么,当我执行以下操作时(它报告“无效日期格式”),为什么它不起作用呢


for(int i=1;i将此添加到包的
pubspec.yaml
文件中:

依赖项:

国际:^0.16.0


更多信息,请参见:

因为DateTime.parse需要4位数字表示年份,2位数字表示月份,2位数字表示日期。在For循环中,我以1开头,这是一个低于9的数字,因此由于它是一个单位数字,解析函数没有收到预期的输入。因此,编译问题。我知道这很晚了,但我希望这样帮助他人。

您能分享完整的错误信息吗?不,您没有迟到。这是错误的正确解释。谢谢
 var now = new DateTime.now();
 print(new DateFormat("yyyy-MM-dd").format(now));