什么是一个字符串,如转换的最佳方式:解析日期字符串.NET
Mon Nov 05 2012 21:27:58 GMT+0000 (GMT Standard Time)
到.NET中
DateTime
?我希望保留尽可能多的日期,即TimeZone。
我想这一点,但它失去了GMT
:
DateTime.ParseExact(date.Substring(0, 24),
"ddd MMM d yyyy HH:mm:ss",
CultureInfo.InvariantCulture);
听起来像是你需要DateTimeOffset'的'混合(这节省了偏移,但没有时区),并表示该时区的字符串。根据字符串的格式,您也可以解析时区。 – CodesInChaos
[datetime.parse并使其使用特定格式](http://stackoverflow.com/questions/341175/datetime-parse-and-making-it-work-with-a-specific-format)? – lstern
@lstern这是一个愚蠢的?这里的问题不仅仅是解析时间,还有保存偏移和时区。 – CodesInChaos