Covert UTC String to UTC Datetime

Discussion in 'ASP .Net' started by =?Utf-8?B?aGVuaw==?=, May 7, 2006.

  1. i have a utc string how can i convert it to utc datetime?
    is this ok: dim UtcDate as Datetime=Datetime.parse(UtcString)?
     
    =?Utf-8?B?aGVuaw==?=, May 7, 2006
    #1
    1. Advertising

  2. "henk" <> wrote in message
    news:...
    >i have a utc string how can i convert it to utc datetime?
    > is this ok: dim UtcDate as Datetime=Datetime.parse(UtcString)?
    >
    >

    Hi Henk,

    Hoe gaat ie?

    There's a whole list of possible date formats. If it contains +0200 (GMT + 2
    hours) there is no native conversion (I have been searching on that as
    well!, only Javascript has an implementation out of the box).

    If it is a date/time string that ends with GMT you can use this

    DateTime conv = DateTime.ParseExact([yourtimestring], "r", null); // instead
    null you also can supply a parameter that seems optional.
     
    Egbert Nierop \(MVP for IIS\), May 7, 2006
    #2
    1. Advertising

  3. hallo egbert,
    bedankt voor je reaktie.
    my string format is like this: ("yyyy-MM-ddTHH:mm:ss.fffZ").
    this is a format that i get from my exchange server and i want to save it in
    my DB.
    is this ok?

    what about to convert it first to localtime and then convert it back to
    UTC?is this ok?
    what's your sugestion?
    thanks in advance.
     
    =?Utf-8?B?aGVuaw==?=, May 7, 2006
    #3
  4. "henk" <> wrote in message
    news:...
    > hallo egbert,
    > bedankt voor je reaktie.
    > my string format is like this: ("yyyy-MM-ddTHH:mm:ss.fffZ").
    > this is a format that i get from my exchange server and i want to save it
    > in
    > my DB.
    > is this ok?
    >
    > what about to convert it first to localtime and then convert it back to
    > UTC?is this ok?
    > what's your sugestion?
    > thanks in advance.
    >


    This is not a UTC date string but a sortable ISO 8601 date-string.

    http://msdn.microsoft.com/library/e...timeformatstringsoutputexample.asp?frame=true

    And you can parse them like this
    DateTime mydate= DateTime.ParseExact("yyyy-MM-ddTHH:mm:ss.fffZ", "s",
    System.Globalization.DateTimeFormatInfo.InvariantCulture);

    And vice versa

    string myiso8601 = myDate.ToString("s");
     
    Egbert Nierop \(MVP for IIS\), May 7, 2006
    #4
    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:
    712
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    538
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    392
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    338
    Martin
    Dec 27, 2008
  5. Justin Voelker
    Replies:
    2
    Views:
    266
    Dr J R Stockton
    Dec 2, 2008
Loading...

Share This Page