xml, DateTime conversions and DateTime fields

Discussion in 'ASP .Net' started by Andy B, Sep 25, 2008.

  1. Andy B

    Andy B Guest

    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.
     
    Andy B, Sep 25, 2008
    #1
    1. Advertising

  2. Andy B

    Guest

    On 25 Wrz, 12:05, "Andy B" <> 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
     
    , Sep 25, 2008
    #2
    1. Advertising

  3. 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/
     
    Martin Honnen, Sep 25, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    720
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    545
    Tim Peters
    Sep 9, 2003
  3. Replies:
    10
    Views:
    709
    Jasen Betts
    Aug 5, 2005
  4. Martin
    Replies:
    0
    Views:
    344
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    767
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page