[英]"String was not recognized as a valid DateTime in Asp.net
string JDate = "21/01/2016 3:47 PM";
when I convert jDate
to DateTime
, An error Occurred 当我将
jDate
转换为DateTime
,发生错误
DateTime journeyDate = DateTime.ParseExact(JDate, "MM/dd/yyyy hh:mm:ss", CultureInfo.InvariantCulture);
String was not recognized as a valid DateTime.
无法将字符串识别为有效的DateTime。
您需要为PM
添加TT
。
You should add tt
form PM as @SLaks said to convert the string
to DateTime
您应该将
tt
形式的PM添加为@SLaks,以将string
转换为DateTime
string JDate = "21/01/2016 3:47 PM";
DateTime journeyDate = DateTime.ParseExact(JDate, "dd/MM/yyyy h:mm tt", CultureInfo.InvariantCulture);
Adding tt will fix the issue. 添加tt将解决此问题。
"dd/MM/yyyy h:mm tt" “ dd / MM / yyyy h:mm tt”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.