xml, DateTime conversions and DateTime fields

A

Andy B

I have a few questions about xml, DateTime conversions and DateTime fields.

1. in the example of DateTime.Now, how would you save it in the format
yyyy-mm-ddThh:mm:ssZ for xml storage?
2. If I have an xml attribute date="2008-09-25T13:15:00Z", How would I load
that into a DateTime variable?
3. Where can I get a list of valid time zone codes for use in xml storage?

Thanks for your help and answers.
P.S. My codebehind is VB.net in vs2008 sp1.
 
R

rrutkowski

I have a few questions about xml, DateTime conversions and DateTime fields.

1. in the example of DateTime.Now, how would you save it in the format
yyyy-mm-ddThh:mm:ssZ for xml storage?
2. If I have an xml attribute date="2008-09-25T13:15:00Z", How would I load
that into a DateTime variable?

I would simply use the ToString and ToDateTime methods of the
XmlConvert class.
 
M

Martin Honnen

Andy said:
2. If I have an xml attribute date="2008-09-25T13:15:00Z", How would I load
that into a DateTime variable?
P.S. My codebehind is VB.net in vs2008 sp1.

You could use LINQ to XML then where you can simply cast the XAttribute
to a DateTime e.g.

Dim bar As XElement = <bar dt="2008-09-25T13:15:00Z"/>
Dim dt As DateTime = CType(bar.Attribute("dt"), DateTime)
Console.WriteLine(dt)
 

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top