473,404 Members | 2,114 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,404 software developers and data experts.

Time Zones?

Hi Folks,

I have a little bit of a problem with my hosting company. The long
and short of it is that they are a US based company and my website is
intended for a UK audience.

When getting dates and times from the SQL server attached to my
hosting account, using VS2005 and asp.net 2.0, it renders the date
correctly, but the time is the actual time in the states.

So a recordset might return 0430 which is actually 1130. Is there
any way I can apply some formatting to this to force it into the
current UK time (either GMT or BST (GMT+1)). I don't want to just add
7 hours on, because that looses daylight savings.

I dont mind whether the formatting is done on a page level, part of
the stored procedures I use, or better still something I can change on
the database itself!

Any ideas?
Craig.

Jan 17 '06 #1
5 987
Joe
Dear Craig,

I think if you use the DATETIME function to get the dates and times for SQL
server, it will get the dates and times from the datetime setting on that
server. So it may have difference between your server and the hosting server,
therefore, it need to ADD 7 hours into the datetimes, i think. Maybe, you can
write a sql server function, say GetRealTimes to get the real times, then you
can use this function in all stored procedures.

Hope this can help you!

Regards
Joe Tsui

"Craig" wrote:
Hi Folks,

I have a little bit of a problem with my hosting company. The long
and short of it is that they are a US based company and my website is
intended for a UK audience.

When getting dates and times from the SQL server attached to my
hosting account, using VS2005 and asp.net 2.0, it renders the date
correctly, but the time is the actual time in the states.

So a recordset might return 0430 which is actually 1130. Is there
any way I can apply some formatting to this to force it into the
current UK time (either GMT or BST (GMT+1)). I don't want to just add
7 hours on, because that looses daylight savings.

I dont mind whether the formatting is done on a page level, part of
the stored procedures I use, or better still something I can change on
the database itself!

Any ideas?
Craig.

Jan 17 '06 #2
On 17 Jan 2006 01:56:30 -0800, "Craig" <cr***********@crawfos.com>
wrote:
Hi Folks,

I have a little bit of a problem with my hosting company. The long
and short of it is that they are a US based company and my website is
intended for a UK audience.

When getting dates and times from the SQL server attached to my
hosting account, using VS2005 and asp.net 2.0, it renders the date
correctly, but the time is the actual time in the states.

So a recordset might return 0430 which is actually 1130. Is there
any way I can apply some formatting to this to force it into the
current UK time (either GMT or BST (GMT+1)). I don't want to just add
7 hours on, because that looses daylight savings.

I dont mind whether the formatting is done on a page level, part of
the stored procedures I use, or better still something I can change on
the database itself!

Any ideas?
Craig.


Here is one way to do this (untested).

Get the time from the server (DateTime ServerTime).

Display: string.Format("{0}", ServerTime.UTC);

I'm assuming that as you say, UTC time will be ok.
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Jan 17 '06 #3
Don't forget about DateTime.UtcNow instead of DateTime.Now. Also MS SQL
has the GETUTCDATE() function instead of GETDATE().

Jan 17 '06 #4
the following will get the system hour offset from gmt,

datediff(hh,getutcdate(),getdate())

use dateadd with this value, plus your timezone offset from gmt and your
done. you could write a simple user defined function to convert server
datetime to your local datetime.

-- bruce (sqlwork.com)

"Craig" <cr***********@crawfos.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi Folks,

I have a little bit of a problem with my hosting company. The long
and short of it is that they are a US based company and my website is
intended for a UK audience.

When getting dates and times from the SQL server attached to my
hosting account, using VS2005 and asp.net 2.0, it renders the date
correctly, but the time is the actual time in the states.

So a recordset might return 0430 which is actually 1130. Is there
any way I can apply some formatting to this to force it into the
current UK time (either GMT or BST (GMT+1)). I don't want to just add
7 hours on, because that looses daylight savings.

I dont mind whether the formatting is done on a page level, part of
the stored procedures I use, or better still something I can change on
the database itself!

Any ideas?
Craig.

Jan 17 '06 #5
Thanks folks - I have used different bits of each of your suggestions
in different places across my project. Thank you.

Jan 19 '06 #6

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

Similar topics

6
by: David Graham | last post by:
Hi I have asked this question in alt.php as the time() function as used in setcookie belongs to php - or does it belong equally in the javascript camp - bit confused about that. Anyway, can anyone...
11
by: lduperval | last post by:
Hi, I`m trying to do date calculations in three types of time zones: local, GMT and specified. The issue I am facing is that I need to be able to specify a date in the proper time zone, and I`m...
1
by: heirou | last post by:
I'm a novice in this subject....I've made a database that requires a time conversion. For example, if local time is 1200, determine the time in Korea. I use two fields: a date field, and a time...
6
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel...
0
by: Sabotage | last post by:
Hi all, I am looking to download time zones list for my multilingual software. I found time zones list in english here:...
13
by: maflatoun | last post by:
Hi, I have the following function to convert UTC time to Local time. It works perfect for GMT- (Minus) time zones however it provides incorrect results for GMT+(Plus) time zones? // Format to...
3
by: Satish Itty | last post by:
Hi all, I have a big problem in my hands and not sure how I can fix this. Any suggestions would be greatly appreciated. I have a .NET 3 tier app developed in VS2003 and .NET 1.1. the client is a...
6
by: dredge | last post by:
Hi, the server that hosts my PHP pages has its clock set to Greenwich Mean Time (GMT timezone 0). I need for my PHP scripts to have access to my local time which is Central Standard Time in the...
10
by: WebCM | last post by:
There is a function: http://paste.ubuntu.com/21865 It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one...
0
amitpatel66
by: amitpatel66 | last post by:
Hi All, Find below some useful information about Time Zone Conversion in oracle. Hope this would be helpful for many of them since all the real time projects that we work in follow different time...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
0
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...

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.