When I tried to convert PDT time to en-US
culture it is not working.
DateTime.Parse("Wed, 08 Jun 2012 12:14:14 PDT",new CultureInfo("en-US"));
But this is working
DateTime.Parse("Wed, 08 Jun 2012 12:14:14",new CultureInfo("en-US"));
When I tried to convert PDT time to en-US
culture it is not working.
DateTime.Parse("Wed, 08 Jun 2012 12:14:14 PDT",new CultureInfo("en-US"));
But this is working
DateTime.Parse("Wed, 08 Jun 2012 12:14:14",new CultureInfo("en-US"));
You can't use time-zones in DateTime.Parse()
, but you can handle them separately.
Try this:
var time = DateTime.Parse("Fri, 08 Jun 2012 12:14:14",new CultureInfo("en-US"));
var zone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var pdtTime = TimeZoneInfo.ConvertTimeFromUtc(time, zone);
Update 1: Oops, got this the wrong way around. Here is the (correct) counterpart:
var enUsTime = TimeZoneInfo.ConvertTimeToUtc(pdtTime, zone);
Oh, and by the way - your original example will not work because 08 Jun 2012
is not a Wed
, but rather a Fri
... ;)
Update 2:
If all you need is a TimeDate, then you can parse is as follows (lin
using System.Linq; // Include a ref to LINQ
(...)
var originalDate = "Fri, 08 Jun 2012 12:14:14 PDT";
// Use LINQ to fetch the first 25 characters (ignoring "PDT"):
var dateToParse = new string(originalDate.Take(25).ToArray());
var result = DateTime.Parse(dateToParse, new CultureInfo("en-US"));