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. Advertisements

  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. Advertisements

  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. Advertisements

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. Guest
    Replies:
    4
    Views:
    629
    Andrew Thompson
    Jul 29, 2005
  2. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    1,048
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  3. Randall Smith
    Replies:
    2
    Views:
    570
    Gerrit Holl
    Jan 4, 2004
  4. mp
    Replies:
    1
    Views:
    680
    John Machin
    Jul 28, 2006
  5. Martin
    Replies:
    0
    Views:
    644
    Martin
    Dec 27, 2008
  6. Replies:
    2
    Views:
    1,063
    M.-A. Lemburg
    Jan 6, 2009
  7. NiklasRTZ

    datetime.datetime. or datetime. ?

    NiklasRTZ, Oct 8, 2009, in forum: Python
    Replies:
    10
    Views:
    760
    niklasr
    Oct 11, 2009
  8. Justin Voelker
    Replies:
    2
    Views:
    479
    Dr J R Stockton
    Dec 2, 2008
Loading...