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

问题:

在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);

 

posted @ 2019-01-02 10:39  不火  阅读(4015)  评论(5编辑  收藏  举报