-1

Possible Duplicate:
Parse DateTime with timezone of form PST/CEST/UTC/etc

I have a datetime string = "10/09/2012 5:00 pm PST" How do I convert this into DateTime using DateTime.ParseExact(). I am looking for the literal that will match PST or EST.

Community
  • 1
  • 1
vijayst
  • 20,359
  • 18
  • 69
  • 113
  • Question already asked here: [http://stackoverflow.com/q/241789/1252575][1] [1]: http://stackoverflow.com/q/241789/1252575 – Nickon Oct 09 '12 at 13:02
  • I don't think .NET supports timezone *names*, only *offsets*, e.g. -4:00 – Kendall Frey Oct 09 '12 at 13:04
  • This can also help you.. http://stackoverflow.com/questions/1886444/c-sharp-how-to-convert-string-to-datetime-where-the-string-can-have-any-of-th – Vinoth Oct 09 '12 at 13:05
  • I saw the post. But, is there any other elegant option. I do not have a mapping of all Timezone and the Timezone offset. – vijayst Oct 09 '12 at 13:05
  • http://stackoverflow.com/questions/919244/converting-string-to-datetime-c-net – Vinoth Oct 09 '12 at 13:05

1 Answers1

0

Replace the PST with the UTC offset, I think it should work:

string value = "10/09/2012 5:00 pm PST";
value = value.Replace ("PST", "−8");

DateTime.ParseExact (value, "M/d/yyyy h:mm tt z", Culture....);
tozka
  • 3,211
  • 19
  • 23