The specified value "2019-1-2" does not conform to the required format, "yyyy-MM-dd&q

Posted gangler

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The specified value "2019-1-2" does not conform to the required format, "yyyy-MM-dd&q相关的知识,希望对你有一定的参考价值。

问题:

在cshtml中转换的日期格式错误,前端报错:The specified value "2019-1-2" does not conform to the required format, "yyyy-MM-dd"

 

导致原因:

由于时间格式没有完全匹配,"yyyy-MM-dd"应该对应"2019-01-02"

 

修改代码:

string.Format("{0:yyyy-MM-dd}", DateTime.Now);

 

以上是关于The specified value "2019-1-2" does not conform to the required format, "yyyy-MM-dd&q的主要内容,如果未能解决你的问题,请参考以下文章