Covert UTC String to UTC Datetime

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have a utc string how can i convert it to utc datetime?
is this ok: dim UtcDate as Datetime=Datetime.parse(UtcString)?
 
henk said:
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.
 
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.
 
henk said:
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");
 
Back
Top