all groups > dotnet web services > may 2005 >
You're in the

dotnet web services

group:

universal time problem



universal time problem thomasamillergoogle NO[at]SPAM yahoo.com
5/29/2005 8:46:28 PM
dotnet web services: 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
Re: universal time problem Dave A
5/30/2005 12:00:00 AM
I had a similar problem recently and it was because a computer had the right
local time, the wrong time zone and therefore the wrong UTC time. Are the
timezones and local times correct on the computers? (I am sure they are -
you just have to ask this question)

[quoted text, click to view]

Re: universal time problem William Stacey [MVP]
5/31/2005 12:00:00 AM
Need some more info. Print the UTC when you create it, print the wire
formate and print it when the service gets it before storing it and see
where it is getting changed.

--
William Stacey [MVP]

[quoted text, click to view]

RE: universal time problem asanford
8/8/2005 11:50:47 AM
[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]
AddThis Social Bookmark Button