473,623 Members | 3,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.UserLa nguages, 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 8033
you will have to use javascript date function in a sniffer page.
<form method=post action='myRealF irstPage.aspx'>
<input type='hidden' name='dateOffse t'>
<script>
document.forms[0].dateOffset.val ue = (new Date).getTimezo neOffset();
document.forms[0].submit();
</script>
</form>

-- bruce (sqlwork.com)

"rgrandidie r" <rg*********@di scussions.micro soft.com> wrote in message
news:09******** *************** ***********@mic rosoft.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.UserLa nguages, 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.kristianse n(AT)bekk.no
"rgrandidie r" 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.UserLa nguages, 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.co m/simple/?ip=<the ip address here>&get=timez one 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.kristianse n(AT)bekk.no
"rgrandidie r" 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
4138
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 starting to crack, columns getting corrupted. Can't handle the volume of data and number of columns. Sql Server has no problem. But displaying the data is the big deal. The end users want to be able to scroll acros a page to the colum of their...
8
9241
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 time? Thanks in advance for any advice.
2
1457
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 message in the lower left corner saying Downloading...) and my hard disk churns away for a 2-4 seconds and then displays the "can't display this page" (standard explorer type message when a web site can't be found). Example
2
1792
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 site to read a message posted by someone in New York, how do you display the time from the timestamp in Pacific time, but when someone in New York views the message, the time stamp is in Eastern Standard time? When I store messages in my SQL...
0
1164
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 page count of 20. This site executes successfully on my local machine and indexing service. When ran on the intended server, the app retrieves the record count, then binds the data in the 2nd DS, but doesn't display the records bound to the...
2
3352
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 and other other half I need to add 3 hours. I was trying to use IsDaylightSavingTime by passing the local date time but it is never daylight savings so it always returns false. Is there a way to force the method to look at the time as ET or is...
9
2579
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" runat="server"/> <asp:Label ID="CompanyPicture" runat="server"/> I have 2 links that open the windows to preview these images. The previewed images are done on separate html pages that do nothing but display the
1
2134
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" in my custom browser, I look into the local cache folder for "www.msn.com" and display its contents. A not-so-good idea to achieve this is to iterate through the 'Temporary Internet Files' folder contents, one by one, until I find the correct...
3
2837
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 IE? Thanks, -Billy zhang
0
8162
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8603
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7134
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6104
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5560
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2593
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.