Problem Converting DateTime

G

Guest

Hi,

I have time in the following format...

Tue, 8 May 2007 13:38:00 EDT

How can I convert it DateTime? Convert.ToDateTime works fine if the Time
Zone is GMT like
Tue, 8 May 2007 13:38:00 GMT

Is there a specified way to accomplish this or would I have to do some hacks?

Thnx
 
M

Michael Nemtsev

Hello mavrick_101,

Use DateTime.ParseExact with
expected format as "string[] expectedFormats = { "ddd", "g", "MMM", "F",
"h", "mm", "ss", "zz"};" (no place to check it)

See MSDN for "Custom DateTime Format Strings" http://msdn2.microsoft.com/en-us/library/8kb3ddd4.aspx

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

m> Hi,
m>
m> I have time in the following format...
m>
m> Tue, 8 May 2007 13:38:00 EDT
m>
m> How can I convert it DateTime? Convert.ToDateTime works fine if the
m> Time Zone is GMT like Tue, 8 May 2007 13:38:00 GMT
m>
m> Is there a specified way to accomplish this or would I have to do
m> some hacks?
m>
m> Thnx
m>
 
A

Alexey Smirnov

Hi,

I have time in the following format...

Tue, 8 May 2007 13:38:00 EDT

How can I convert it DateTime? Convert.ToDateTime works fine if the Time
Zone is GMT like
Tue, 8 May 2007 13:38:00 GMT

Is there a specified way to accomplish this or would I have to do some hacks?

Thnx

remove EDT
parse date
add time offset
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top