-2

How to convert "Fri Jul 11 2014 01:30:00 GMT-0700 (Pacific Daylight Time)" to Datetime with the format of "dd/MM/yyyy HH:mm:ss" in C#?

Marc B
  • 356,200
  • 43
  • 426
  • 500
arlen
  • 1,065
  • 1
  • 16
  • 31
  • Dupe: http://stackoverflow.com/questions/3511578/how-to-convert-string-to-datetime-in-specified-format?rq=1 – Marc B Jul 11 '14 at 22:03
  • If it is dupe, any solution will be accepted please. – arlen Jul 11 '14 at 22:08
  • possible duplicate of [Convert UTC/GMT time to local time](http://stackoverflow.com/questions/179940/convert-utc-gmt-time-to-local-time) – leppie Jul 11 '14 at 22:17
  • http://stackoverflow.com/questions/19879817/c-sharp-parse-gmt-date-string-to-datetime?rq=1 – leppie Jul 11 '14 at 22:20

1 Answers1

2
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);
Ross Presser
  • 6,027
  • 1
  • 34
  • 66