【问题标题】:Convert String with GMT foramt to Datetime将 GMT 格式的字符串转换为日期时间
【发布时间】:2014-07-11 22:00:21
【问题描述】:

如何将“Fri Jul 11​​ 2014 01:30:00 GMT-0700(太平洋夏令时间)”转换为日期时间 C#格式为“dd/MM/yyyy HH:mm:ss”?

【问题讨论】:

标签: c# datetime


【解决方案1】:
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);

【讨论】:

    猜你喜欢
    • 2018-04-13
    • 1970-01-01
    • 2011-10-07
    • 1970-01-01
    • 2020-04-24
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    相关资源
    最近更新 更多