Time Zones?

Discussion in 'ASP .Net' started by Craig, Jan 17, 2006.

  1. Craig

    Craig Guest

    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.
     
    Craig, Jan 17, 2006
    #1
    1. Advertising

  2. 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.
    >
    >
     
    =?Utf-8?B?Sm9l?=, Jan 17, 2006
    #2
    1. Advertising

  3. On 17 Jan 2006 01:56:30 -0800, "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.


    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
     
    Otis Mukinfus, Jan 17, 2006
    #3
  4. Craig

    Joey Guest

    Don't forget about DateTime.UtcNow instead of DateTime.Now. Also MS SQL
    has the GETUTCDATE() function instead of GETDATE().
     
    Joey, Jan 17, 2006
    #4
  5. Craig

    Bruce Barker Guest

    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" <> wrote in message
    news:...
    > 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.
    >
     
    Bruce Barker, Jan 17, 2006
    #5
  6. Craig

    Craig Guest

    Thanks folks - I have used different bits of each of your suggestions
    in different places across my project. Thank you.
     
    Craig, Jan 19, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CJ
    Replies:
    2
    Views:
    584
  2. Eric Wertman

    time module question - time zones

    Eric Wertman, May 21, 2008, in forum: Python
    Replies:
    0
    Views:
    502
    Eric Wertman
    May 21, 2008
  3. Eric Wertman

    Re: time module question - time zones

    Eric Wertman, May 21, 2008, in forum: Python
    Replies:
    0
    Views:
    505
    Eric Wertman
    May 21, 2008
  4. Harlan Messinger

    Dates, time zones,daylight saving time

    Harlan Messinger, Apr 15, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    1,019
    Eric Isaacs
    Apr 16, 2010
  5. David Graham

    cookie expire time and time zones

    David Graham, Nov 20, 2003, in forum: Javascript
    Replies:
    6
    Views:
    271
    Dr John Stockton
    Nov 22, 2003
Loading...

Share This Page