Parasing a Date/Time string, to DateTime

C

Craig Lister

I am getting a date time in the following format:

2010-07-03T19:18:57+10:00

And I need to store that in a DateTiem property.

I am trying to use:
lastUpdate = DateTime.ParseExact(nodeRss.ChildNodes.InnerText,
"yyyy-MM-dd HH:mm:ss", null);

but failing. How should this be done?
 
A

Arne Vajhøj

I am getting a date time in the following format:

2010-07-03T19:18:57+10:00

And I need to store that in a DateTiem property.

I am trying to use:
lastUpdate = DateTime.ParseExact(nodeRss.ChildNodes.InnerText,
"yyyy-MM-dd HH:mm:ss", null);

but failing. How should this be done?


Try with:

"yyyy-MM-ddTHH:mm:sszzzz"

Arne
 
A

Arne Vajhøj

I am getting a date time in the following format:

2010-07-03T19:18:57+10:00

And I need to store that in a DateTiem property.

I am trying to use:
lastUpdate = DateTime.ParseExact(nodeRss.ChildNodes.InnerText,
"yyyy-MM-dd HH:mm:ss", null);

but failing. How should this be done?


Try with:

"yyyy-MM-ddTHH:mm:sszzzz"


Another approach would be:

DateTimeOffset.Parse(nodeRss.ChildNodes.InnerText, null,
DateTimeStyles.RoundtripKind)

Arne
 

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