Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change time based on client timezone

Posted on 2011-02-14
6
Medium Priority
?
605 Views
Last Modified: 2012-05-11
I am querying a datetime field from SQL database to show the date and time of an event. The person who sets the event date and time is in one particualar timezone (Mountain Time USA), but users may be in a different time who see the event date and time. Is there a way to have the time adjusted based on the location of the user in a different timezone? For example, if someone in California views the same info, it will subtract one hour so the time they view will coordinate with the user who sets the time?

Currently, I just have something like:  "Select right(convert(varchar(19), EventStart, 100),6) As Time from Event Where something = @something"

That gives me the time from the datetime sql field. but need to adjust it depending on where someone might be in multiple different timezones.

Thank you.
0
Comment
Question by:mlg101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 34890422
Why not just use the GMT time in all records?
0
 
LVL 1

Author Comment

by:mlg101
ID: 34890436
How does that work and how do you do it? does it automatically adjust then?
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34890437
Normally I think one would always store Greenwich Mean Time (UTC) in the database, then you can always convert it to a local time for any user with DateTime.ToLocalTime() - otherwise your database needs some means to indicate which timezone the data was originally stored for.  I'm not intimately familiar with SQL's datetime, but I don't think it inherently includes this information.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 34896007
>The person who sets the event date and time is in one particualar timezone (Mountain Time USA)
So you probably do not need to worry about the SOURCE timezone.

Try this example
http://www.c-sharpcorner.com/UploadFile/vendettamit/1065/


Following link shows how to get client timezone using JavaScript. Its for PHP but I think would require little modification

http://stackoverflow.com/questions/13/how-can-i-determine-a-web-users-time-zone


Following link shows how to convert between different timezones

http://www.dotnetcurry.com/ShowArticle.aspx?ID=593
0
 
LVL 1

Author Closing Comment

by:mlg101
ID: 34899007
Followed the 3rd link and it was what I needed. Thank you.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34905855
Glad to help :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question