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

猜你喜欢

转载自www.cnblogs.com/gangler/p/10207339.html