[英]How Do I Convert this specific string to a Datetime in c#?
I'm really confused I've tried a lot to get it to work. 我真的很困惑,我已经做了很多尝试才能使其正常工作。
This is the date I'm trying to convert: 这是我要转换的日期:
6/29/17, 1:15 PM
17-6 / 29下午1:15
This is the code: 这是代码:
DateTime.ParseExact(dateString, "MM/dd/yy, HH:mm tt", System.Globalization.CultureInfo.InvariantCulture);
Anyone knows how to approach this? 有人知道该如何处理吗?
You need to use M/dd/yy, h:mm tt
format instead. 您需要改用
M/dd/yy, h:mm tt
格式。
M
specifier is for single digit month numbers without leading zero. M
指示符用于单位数月份数字,且不以零开头。 h
specifier is for single hour digit 12-hour format without leading zero. h
指示符用于单小时数字12小时格式,前导零。 DateTime.ParseExact(dateString, "M/dd/yy, h:mm tt", CultureInfo.InvariantCulture);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.