473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How can I display local time from UTC?

I have a SQL table that stores the UTC time for a column, I then want to
display the UTC time to the user in their local time.

My approach is to have the user set their time zone via their user profile.
Then to use that setting to convert the UTC date/time to the users local time.

I am using C# via ASP.Net. Any suggestions? I thought I had found
something using the CultureInfo class and Response.UserLanguages, however,
this always displays the same time regardless if I am on Eastern time or
Pacific time.

Any help would be greatly appreciated.
--
Robert
Nov 19 '05 #1
5 8017
you will have to use javascript date function in a sniffer page.
<form method=post action='myRealFirstPage.aspx'>
<input type='hidden' name='dateOffset'>
<script>
document.forms[0].dateOffset.value = (new Date).getTimezoneOffset();
document.forms[0].submit();
</script>
</form>

-- bruce (sqlwork.com)

"rgrandidier" <rg*********@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
I have a SQL table that stores the UTC time for a column, I then want to
display the UTC time to the user in their local time.

My approach is to have the user set their time zone via their user
profile.
Then to use that setting to convert the UTC date/time to the users local
time.

I am using C# via ASP.Net. Any suggestions? I thought I had found
something using the CultureInfo class and Response.UserLanguages, however,
this always displays the same time regardless if I am on Eastern time or
Pacific time.

Any help would be greatly appreciated.
--
Robert

Nov 19 '05 #2
Thanks, I was looking for a server side solution. Since JavaScript being
turned on is no guarantee.
--
Robert
Nov 19 '05 #3
Do you want to automatically fetch the users timezone (form the windows
environment), or do you want to use the timezone (e.g. UTC+1) information
from the users profile?

--
Bent Kristiansen
bent.kristiansen(AT)bekk.no
"rgrandidier" wrote:
I have a SQL table that stores the UTC time for a column, I then want to
display the UTC time to the user in their local time.

My approach is to have the user set their time zone via their user profile.
Then to use that setting to convert the UTC date/time to the users local time.

I am using C# via ASP.Net. Any suggestions? I thought I had found
something using the CultureInfo class and Response.UserLanguages, however,
this always displays the same time regardless if I am on Eastern time or
Pacific time.

Any help would be greatly appreciated.
--
Robert

Nov 19 '05 #4
If it was technically possible without the user being able to turn off the
code I would like to get it from the user's environment (the less the user
has to do the better), however, if not possible then I will have the user set
up their profile to tell me what their time zone is.

After I figured out this issue, I still need to figure out daylight savings
time issues throughout the world in order to display the time appropriately.
--
Robert
Nov 19 '05 #5
I do not think it is possible get this information based on e.g. CultureInfo.
Then I see only two alternatives to solve this (without using javascripts).

1. Ask the user to save/choose their timezone in +/- hours or by "timezone
name" ("Mountain Daylight Time", "Mountain Standard Time", "Canberra,
Melborne, Sydney", etc.), or by abbreviations see:
(http://www.worldtimezone.com/wtz-nam...onenames.html). But this is not
a good solution for the user...

2. Write a few server side code lines that sends the web users IP address to
http://www.showmyip.com/simple/?ip=<the ip address here>&get=timezone or
another site that locates the location and timezone of a IP address.
Unfortunately you have to subscribe for the service at www.showmyip.com, but
there may be a free service available also.

--
Bent Kristiansen
bent.kristiansen(AT)bekk.no
"rgrandidier" wrote:
If it was technically possible without the user being able to turn off the
code I would like to get it from the user's environment (the less the user
has to do the better), however, if not possible then I will have the user set
up their profile to tell me what their time zone is.

After I figured out this issue, I still need to figure out daylight savings
time issues throughout the world in order to display the time appropriately.
--
Robert

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: Rich | last post by:
I'm sure it sounds kinda nutty to display 200 columns and 500,000 rows of data. But I have been pulling data from a Lotus Notes database into Sql Server for a while now, but Lotus Notes is...
8
by: Monty | last post by:
Let's say you provide an online service from 7:00AM to 6:00PM Eastern Time (daylight time in the summer). Is there way of showing these hours of availability on a web page in the user's local...
2
by: Rob R. Ainscough | last post by:
I have an interesting problem that is either a bug or just some local issue with my PC (probably the later). If I place my cursor on a word and hit F1 for help, it goes thru a process (see a...
2
by: David Berman | last post by:
Suppose you have a bulletin board where of course people can post messages and read messages composed by other people. Each message has a time stamp on it. When someone in California comes to the...
0
by: mkd1919 | last post by:
I have a website that performs a search on an indexing service and returns the results. During the initial load, I get the recordcount through a DS, then bind a DataList using a second DS with...
2
by: Max | last post by:
I need to display time as Eastern Time. The problem I'm having is that our server is in Arizona where there is no Daylight Savings time. That means half the year I need to add 2 hours to the time...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
1
by: dearprasan | last post by:
I have a custom browser application built in C#. I want to access the Internet Explorer's Cache to display contents on this custom browser application. For example: If the user types "www.msn.com"...
3
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I have a asp.net app, in the page there is a scan activex which could scan and save a jpg file in client harddisk. How could we access and display this jpg file on the fly using js in the client...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.