ISO8601 DateTime format

R

rlaemmler

Hi,

"2006-01-27T07:42:11.3014976-08:00" is an example how a DateTime gets
serialized from a ASP.NET web service. This represents the ISO8601
format. For some reason when I read such a value from a MySQL database,
initialize a DateTime object which gets returned by a web service it
ends up coming back as "2006-01-27T07:42:11". This only happens when
using .NET framework 2.0. In the framework 1.1 it always serialized the
full DateTime including the timezone offset as shown on top.

Does anybody know how to make sure it always serializes it to
"2006-01-27T07:42:11.3014976-08:00"?

Thanks.
 
K

Kevin Spencer

Actually, both of the DateTime formats you posted are in compliance with
ISO8601. The difference is that one represents a DateTime in which the Time
Zone is known. The other represents a DateTime in which the Time Zone is not
known.

"2006-01-27T07:42:11.3014976-08:00"

The first portion of this DateTime value is:

yyyy-mm-dd

The second portion is:

Thh:mm.ssms

The third part is:

-(+)hh:mm

The third part indicates the TimeZone, the offset from UTC time.

"2006-01-27T07:42:11"

As you can see, apparently this DateTime is not stored with Time
Zone-specific information in it, and without milliseconds. I would recommend
reading up on the MySql data type being used in your database for this
value.

See http://www.w3.org/TR/NOTE-datetime for more information.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 

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

Top