Problems with DateTime.ParseExact()
本文关键字:ParseExact DateTime with Problems | 更新日期: 2023-09-27 18:08:11
我有问题与下一个解析精确:
Time="4/1/2015 7:10:31 a m"
FechaLeida = DateTime.ParseExact(Time, "M/d/yyyy hh:mm:ss tt", new CultureInfo("en-US"));
我得到一个异常:
这个字符串不能被识别为有效的日期时间
你知道我做错了什么吗?
您的格式和日期不匹配,您需要使用07
in hour,因为您提到了hh
,而且我有空间作为a m
var time="4/1/2015 07:10:31 am";
FechaLeida = DateTime.ParseExact(time, "M/d/yyyy hh:mm:ss tt", new CultureInfo("en-US"));
或
var time="4/1/2015 7:10:31 am";
FechaLeida = DateTime.ParseExact(time, "M/d/yyyy h:mm:ss tt", new CultureInfo("en-US"));