ablesa
asked on
Setting Time Zone for Windows Form App
I have a .NET visual Studio 2005 question... I have a client app that runs off desktops across the world. It allows the user's to run in their local culture. All of the database access is handled on a central server (located in the US on the east coast in the EST time zone). We use remoting to enable the client and the "business" (database) code to communicate and subsequently issue stored proc calls. We wanted to have all date/times that were saved into the database be in the EST timezone (most users are in the US and it seemed confusing to store dates/times in local time zones and really not have a reference as to what time zone it was in and therefore, not knowing REALLY what time an action was initiated).
Anyway, currently, when the users outside of the EST time zone use the system, their local date/time is entered into the database.
Is there an EASY way to change the timezone used by a thread (similar to the way we can change the culture of the thread) so that all interaction for the client thread could be done in the same timezone as the dates/times we want to store in the database? I don't really want to change the visual format of the dates/times, just the zone.
Anyway, currently, when the users outside of the EST time zone use the system, their local date/time is entered into the database.
Is there an EASY way to change the timezone used by a thread (similar to the way we can change the culture of the thread) so that all interaction for the client thread could be done in the same timezone as the dates/times we want to store in the database? I don't really want to change the visual format of the dates/times, just the zone.
I reckon the best way would be to write times in your DB in UTC. Easy to convert from local to UTC (myLocalTime.ToUniversaTim e) and back the other way (myUTCTime.ToLocalTime).
What I would do is to have an extra filed in my database (e.g. EST_Timezone) and set its default value to Now()
So any time a user adds a new record the field will have the server time
So any time a user adds a new record the field will have the server time
ASKER
thanks to you both for your comments. Those solutions might have been the way to go 9 months ago, but now, we are testing and getting ready to deploy to users by Aug 1. It seems that I will have to convert the dates to EST before running the stored procs.... If you have any other "quick fix" ideas, please let me know.
Thanks!
Thanks!
I still suggest... Have an extra filed in your database (e.g. EST_Timezone) and set its default value to Now(), then have the stored procs to return this value to you. It is safest than converting it programmatically
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Thank you for taking the time to make us "smarter" with your time investment.
Have fun coding...;)
Have fun coding...;)