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