【发布时间】:2014-07-11 22:00:21
【问题描述】:
如何将“Fri Jul 11 2014 01:30:00 GMT-0700(太平洋夏令时间)”转换为日期时间 C#格式为“dd/MM/yyyy HH:mm:ss”?
【问题讨论】:
-
如果是骗子,请接受任何解决方案。
如何将“Fri Jul 11 2014 01:30:00 GMT-0700(太平洋夏令时间)”转换为日期时间 C#格式为“dd/MM/yyyy HH:mm:ss”?
【问题讨论】:
String inputString="Fri Jul 11 2014 01:30:00 GMT-0700 (Pacific Daylight Time)";
// we have no need of the parenthetical, get rid of it
inputString = Regex.Replace(inputString, " \\(.*\\)$", "");
// exact string format ... 'GMT' is literal
DateTime theDate = DateTime.ParseExact(inputString,"ddd MMM dd yyyy HH:mm:ss 'GMT'zzz",
System.Globalization.CultureInfo.InvariantCulture);
【讨论】: