Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Time Zones?

Reply
Thread Tools

Time Zones?

 
 
Craig
Guest
Posts: n/a
 
      01-17-2006
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.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      01-17-2006
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.
>
>

 
Reply With Quote
 
 
 
 
Otis Mukinfus
Guest
Posts: n/a
 
      01-17-2006
On 17 Jan 2006 01:56:30 -0800, "Craig" <(E-Mail Removed)>
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
 
Reply With Quote
 
Joey
Guest
Posts: n/a
 
      01-17-2006
Don't forget about DateTime.UtcNow instead of DateTime.Now. Also MS SQL
has the GETUTCDATE() function instead of GETDATE().

 
Reply With Quote
 
Bruce Barker
Guest
Posts: n/a
 
      01-17-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.
>



 
Reply With Quote
 
Craig
Guest
Posts: n/a
 
      01-19-2006
Thanks folks - I have used different bits of each of your suggestions
in different places across my project. Thank you.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
Re: interpreting the fractional portion of time.clock() vs time.time(0measurements Peter Hansen Python 0 02-22-2006 02:02 PM
Re: interpreting the fractional portion of time.clock() vs time.time()measurements Peter Hansen Python 0 02-22-2006 12:03 AM
time.clock() or time.time() peterbe@gmail.com Python 8 08-05-2005 01:51 PM
delta time = time stop - time start engsol Python 2 01-26-2004 12:06 PM



Advertisments