We have an ASP.Net 2.0 web application that works with a server in the Midwest (Eastern Standard Time). At the moment, all our clients are in the same time zone as the server. We are launching another server online in Arizona (Mountain Standard Time).
We save all our time in a SQL 2005 database using C # codebehind DateTime.UtcNow.
During testing, we encountered some time zone conversion problems. Our problem is that in the web browser, our time displays "Mountain Standard Time" instead of the time zone that we are testing, from which "Eastern Standard Time" comes.
When we enter new information, it is stored in UTC format in the database, but when we move on to viewing this information in a browser, it displays Mountain Standard Time. Below is the code that takes the UTC value from the database and displays it in the browser.
lblUpdatedDate.Text = Convert.ToDateTime(dr["UpdatedDate"]).ToLocalTime().ToString();
The above code returns Mountain Standard Time, where the server is located, and not the Eastern Standard Time, in which the browser works. How do we get time to display where the user is?
source
share