[at least in .net 1.1), System.DateTime will not serialize correctly if it's
in UTC - it will always write the value of the DateTime object and then
append the PC's UTC offset. So if the local pc is UTC-5, and you have a
DateTime object that is set to 8/29/2005 @ 11:14:15am (UTC, non-utc, it
doesn't matter, as DateTime doesn't track this info - therein lies the
problem), it will serialize as "2005-08-29T11:14:15-05:00". Obviously, if
you have set this to UTC, it will be wrong. So, always serialize DateTime
objects only in local pc time.
[quoted text, click to view] "thomasamillergoogle@yahoo.com" wrote:
> I am building a .net client application that will be deployed world
> wide.
>
> The client can schedule reminders. To do this the user picks the
> datetime he wants the reminder sent, _I convert the datetime to
> Universal time_, and it is submitted through a web service - where it
> finally saved to sql server.
>
> I have one local webservice for my testing purposes, I will call this
> service A.
>
> I have production webservice also, I will call this service B. This
> webservice is in a different timezone
>
> When my client uses webervice A or B to save the reminder it ends up
> as a different date in the database! Even though I converted the
> datetime to Universal _in the client application_!
>
> This is driving me somewhat crazy. What can I do to fix this behavior?
>
> I have read in many places that it is best practice to:
>
> - only write UTC times to the database
> - do every calculation/comparison in UTC.
> - only use local time (DST or not) to VISUALIZE to the user.
> - if user enters (local) time, IMMEDIATELY convert to UTC,
> and only save it as UTC, NEVER as local.
>
>
> Tom
>