Covert UTC String to UTC Datetime

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

Egbert Nierop \(MVP for IIS\)

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

Guest

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

Egbert Nierop \(MVP for IIS\)

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top