Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   xml, DateTime conversions and DateTime fields (http://www.velocityreviews.com/forums/t636950-xml-datetime-conversions-and-datetime-fields.html)

Andy B 09-25-2008 10:05 AM

xml, DateTime conversions and DateTime fields
 
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.



rrutkowski@gmail.com 09-25-2008 10:23 AM

Re: xml, DateTime conversions and DateTime fields
 
On 25 Wrz, 12:05, "Andy B" <a_bo...@sbcglobal.net> wrote:
> 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.

--
Rudy

Martin Honnen 09-25-2008 01:43 PM

Re: xml, DateTime conversions and DateTime fields
 
Andy B wrote:

> 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)

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


All times are GMT. The time now is 11:16 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.