0

I have a simple tool that allows an employee to enter the ItemID of the work item they are working on and track the time it takes them to complete it. There is a Begin and End button which creates a timestamp in the database.

Since we have users all over the world that use this, we want to provide a more unique user experience in some areas which is where my question comes into play.

I currently store the timestamp as a Datetime type in the MSSQL Database. The timestamp is GETUTCDATE() which keeps everything consistent no matter where the user is actually located.

What I am now wanting to do is create a user setting that allows them to choose a timezone they want use when viewing the data on the site. For example, although everything is stored in the UTC timezone, a user can set their preference to Mountain Standard Time.

I then want to show all of that data in that timezone. When the user visits the site, we find out what timezone they want to view the data in. Based on that timezone, we show all the start and stop times accordingly.

Here is my question:

What should I be saving in the database as the users "preferred timezone"? Is this an integer (offset of hours) or is this an actual timezone name that I can use to determine the difference?

Second question is: How can I go about using this preference to alter the time and show it based on that users preference? Should this be done in the query or is there a front end plugin I can pass the UTC time and timezone preference to in order to show it?

  • Not sure if your question is purely UX related... In any case, storing the dates in the databse in UTC is the only way to go. The offset of the user's timezone should maybe be 2 things: a float offset (not all timezone offstes are an exact multiple of 1 hour) and a boolean to indicate if the user is in a timezone with daylight savings time. – Bart Gijssens Sep 7 '15 at 6:30
  • Thanks- I guess my question is a little confusing so I apologize. Storing the time stamps as utc makes sense and it's what I already do. I now need to create a drop down of time zones and allow the user to select their preference in their profile. Depending on what they chose, it shows all the dates on the site with that time zones offset. That's kinda where I'm stuck- trying to figure out what the values of the drop down should be and the best way to covert the times. If on the UI side, I need a way to pass the utc time stamp along with the time zone they selected and changed all the times. – SBB Sep 7 '15 at 16:10
  • Why don't you do it in the same way as Windows does it? I think you can in fact get all the different timezones from the OS by an API and default the selection to the same one as the OS. – Bart Gijssens Sep 8 '15 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.