Time zones: Pretending to be somewhere else

Discussion in 'ASP .Net' started by Nathan Sokalski, Jan 21, 2006.

  1. I use a webhosting service that is something like halfway around the world
    from me and most of the people that will be viewing my site (and I am
    assuming their server is too). This obviously has very little effect on what
    I can do, but there is one thing that I would like to know how to do (if it
    can be done). When I do something that involves getting the current date or
    time, my application gets it from the server it is running on, which means
    it could be off by as much about half a day, and many of my pages preselect
    the current date for certain things, but sometimes that is incorrect for the
    same reason. Is there any way to make my entire application automatically
    adjust these values to the timezone I am in (is there a way I can put a
    setting in the web.config or Global.asax.vb file or something that says
    "where I am" so it adjusts these values based on where the server says it
    is)? This would make things much less complicated for me, as well as make it
    easier if I ever have to move my application to a different webhost or
    server. Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
     
    Nathan Sokalski, Jan 21, 2006
    #1
    1. Advertising

  2. Nathan Sokalski

    EJD Guest

    EJD, Jan 21, 2006
    #2
    1. Advertising

  3. That may be useful in doing specific situations, but I was looking for
    something more centralized, something where I wouldn't need to add the code
    for every situation involving a datetime variable (that would involve a lot
    of extra code). Any other thoughts?
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "EJD" <> wrote in message
    news:...
    > Nathan,
    >
    > You may want to check out either the locally installed .net help or
    > this article - they're basically the same thing. I think it'll help...
    >
    > http://msdn2.microsoft.com/en-us/library/5hh873ya.aspx
    >
    > Eric David
    >
     
    Nathan Sokalski, Jan 21, 2006
    #3
  4. Nathan Sokalski

    EJD Guest

    I'm not 100% sure but I don't think that you can accurately display the
    local date on a client's machine without writing some "extra" code.
    The server has no idea what time it is where the client is located
    unless you tell it to find out what the local time is on the client
    machine, and then compare it to the server's own time. Maybe this
    could make life easier... but it would require writing some more code.
    http://builder.com.com/5100-6370_14-6016329.html

    Unless someone else knows of a better way... Good luck.
    Eric
     
    EJD, Jan 21, 2006
    #4
  5. We don't use local time for situations like this. We use GMT. This way it's
    always the same world-wide. Once captured we can query the local system for
    its current timezone and adjust--but only if the user has to see this value
    and it must be shown in the local timezone.

    --
    ____________________________________
    William (Bill) Vaughn
    Author, Mentor, Consultant
    Microsoft MVP
    INETA Speaker
    www.betav.com/blog/billva
    www.betav.com
    Please reply only to the newsgroup so that others can benefit.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    __________________________________

    "Nathan Sokalski" <> wrote in message
    news:%...
    >I use a webhosting service that is something like halfway around the world
    >from me and most of the people that will be viewing my site (and I am
    >assuming their server is too). This obviously has very little effect on
    >what I can do, but there is one thing that I would like to know how to do
    >(if it can be done). When I do something that involves getting the current
    >date or time, my application gets it from the server it is running on,
    >which means it could be off by as much about half a day, and many of my
    >pages preselect the current date for certain things, but sometimes that is
    >incorrect for the same reason. Is there any way to make my entire
    >application automatically adjust these values to the timezone I am in (is
    >there a way I can put a setting in the web.config or Global.asax.vb file or
    >something that says "where I am" so it adjusts these values based on where
    >the server says it is)? This would make things much less complicated for
    >me, as well as make it easier if I ever have to move my application to a
    >different webhost or server. Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
     
    William \(Bill\) Vaughn, Jan 21, 2006
    #5
  6. Nathan Sokalski

    clintonG Guest

    This really aggravates the hell out of me. My server is (-06:00 GMT) and the
    2.0 Website Administration Tool for example and other 2.0 controls write
    database entries offset 6 hours into the future. So William, when you mean
    "adjust" you must mean the database administrator or the web developer must
    "adjust" to the fact that they are now compelled to write compensation code
    that somehow captures the date and time of the user and applies an offset to
    accurately record date and time circumstantially.

    The flaw in this reasoning, and correct me if I'm wrong, is the fact that
    the framework does not record which time zone a user is in when it
    automatically records the date and time using "adjusted" GMT values which
    requires the use of an offset. So how is the database administrator or the
    developer supposed to know what offset value to use when they need to work
    with the date and time values at some point in the future?

    As far as I've been able to determine the answer is "they don't." This
    decision by some Microsoft crackhead to force everybody to record data using
    GMT was not thought out well and as usual implemented as crippleware.

    If we are going to be forced to adopt GMT at least the offset value should
    be recorded into the database when the framework uses brute force to record
    the GMT value.

    <%= Clinton Gallagher
    METROmilwaukee (sm) "A Regional Information Service"
    NET csgallagher AT metromilwaukee.com
    URL http://metromilwaukee.com/
    URL http://clintongallagher.metromilwaukee.com/



    "William (Bill) Vaughn" <> wrote in message
    news:%...
    > We don't use local time for situations like this. We use GMT. This way
    > it's always the same world-wide. Once captured we can query the local
    > system for its current timezone and adjust--but only if the user has to
    > see this value and it must be shown in the local timezone.
    >
    > --
    > ____________________________________
    > William (Bill) Vaughn
    > Author, Mentor, Consultant
    > Microsoft MVP
    > INETA Speaker
    > www.betav.com/blog/billva
    > www.betav.com
    > Please reply only to the newsgroup so that others can benefit.
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    > __________________________________
    >
    > "Nathan Sokalski" <> wrote in message
    > news:%...
    >>I use a webhosting service that is something like halfway around the world
    >>from me and most of the people that will be viewing my site (and I am
    >>assuming their server is too). This obviously has very little effect on
    >>what I can do, but there is one thing that I would like to know how to do
    >>(if it can be done). When I do something that involves getting the current
    >>date or time, my application gets it from the server it is running on,
    >>which means it could be off by as much about half a day, and many of my
    >>pages preselect the current date for certain things, but sometimes that is
    >>incorrect for the same reason. Is there any way to make my entire
    >>application automatically adjust these values to the timezone I am in (is
    >>there a way I can put a setting in the web.config or Global.asax.vb file
    >>or something that says "where I am" so it adjusts these values based on
    >>where the server says it is)? This would make things much less complicated
    >>for me, as well as make it easier if I ever have to move my application to
    >>a different webhost or server. Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>

    >
    >
     
    clintonG, Jan 21, 2006
    #6
  7. I'm not certain what is the aggravation here.

    The timezone is not relevant information when you work with an "absolute and
    common" time. Translation to local user timezone just need to be done at the
    very beginning and end. If you remember to only use and manipulate GMT time,
    things just work.

    Think about it -- this works no differently than multi-lingual websites. You
    record data in an absolute and common format like Unicode. You translate
    to/from the user's locale right at the beginning and end, but if you do all
    your manipulation in Unicode, the website should be perfectly I18N.

    --
    //David
    IIS
    http://blogs.msdn.com/David.Wang
    This posting is provided "AS IS" with no warranties, and confers no rights.
    //

    "clintonG" <> wrote in message
    news:...
    > This really aggravates the hell out of me. My server is (-06:00 GMT) and
    > the 2.0 Website Administration Tool for example and other 2.0 controls
    > write database entries offset 6 hours into the future. So William, when
    > you mean "adjust" you must mean the database administrator or the web
    > developer must "adjust" to the fact that they are now compelled to write
    > compensation code that somehow captures the date and time of the user and
    > applies an offset to accurately record date and time circumstantially.
    >
    > The flaw in this reasoning, and correct me if I'm wrong, is the fact that
    > the framework does not record which time zone a user is in when it
    > automatically records the date and time using "adjusted" GMT values which
    > requires the use of an offset. So how is the database administrator or the
    > developer supposed to know what offset value to use when they need to work
    > with the date and time values at some point in the future?
    >
    > As far as I've been able to determine the answer is "they don't." This
    > decision by some Microsoft crackhead to force everybody to record data
    > using GMT was not thought out well and as usual implemented as
    > crippleware.
    >
    > If we are going to be forced to adopt GMT at least the offset value should
    > be recorded into the database when the framework uses brute force to
    > record the GMT value.
    >
    > <%= Clinton Gallagher
    > METROmilwaukee (sm) "A Regional Information Service"
    > NET csgallagher AT metromilwaukee.com
    > URL http://metromilwaukee.com/
    > URL http://clintongallagher.metromilwaukee.com/
    >
    >
    >
    > "William (Bill) Vaughn" <> wrote in message
    > news:%...
    >> We don't use local time for situations like this. We use GMT. This way
    >> it's always the same world-wide. Once captured we can query the local
    >> system for its current timezone and adjust--but only if the user has to
    >> see this value and it must be shown in the local timezone.
    >>
    >> --
    >> ____________________________________
    >> William (Bill) Vaughn
    >> Author, Mentor, Consultant
    >> Microsoft MVP
    >> INETA Speaker
    >> www.betav.com/blog/billva
    >> www.betav.com
    >> Please reply only to the newsgroup so that others can benefit.
    >> This posting is provided "AS IS" with no warranties, and confers no
    >> rights.
    >> __________________________________
    >>
    >> "Nathan Sokalski" <> wrote in message
    >> news:%...
    >>>I use a webhosting service that is something like halfway around the
    >>>world from me and most of the people that will be viewing my site (and I
    >>>am assuming their server is too). This obviously has very little effect
    >>>on what I can do, but there is one thing that I would like to know how to
    >>>do (if it can be done). When I do something that involves getting the
    >>>current date or time, my application gets it from the server it is
    >>>running on, which means it could be off by as much about half a day, and
    >>>many of my pages preselect the current date for certain things, but
    >>>sometimes that is incorrect for the same reason. Is there any way to make
    >>>my entire application automatically adjust these values to the timezone I
    >>>am in (is there a way I can put a setting in the web.config or
    >>>Global.asax.vb file or something that says "where I am" so it adjusts
    >>>these values based on where the server says it is)? This would make
    >>>things much less complicated for me, as well as make it easier if I ever
    >>>have to move my application to a different webhost or server. Thanks.
    >>> --
    >>> Nathan Sokalski
    >>>
    >>> http://www.nathansokalski.com/
    >>>

    >>
    >>

    >
    >
     
    David Wang [Msft], Jan 22, 2006
    #7
  8. Nathan Sokalski

    Ken Schaefer Guest

    Hi Clinton,

    I know you are not the original poster here. And I think you're confusing
    the issue.

    Bill is suggesting that the OP use GMT in his/her app to get around the time
    zone issue. No one is forcing *you* to write anything using GMT, and no one
    is forcing your to write compensation code. When you get the current
    date/time using .NET code, it comes back as the current date/time on the
    server *not* GMT. You do not need to apply an offset.

    There are no "crackheads" at Microsoft, and frankly if you want to make
    inaccurate and meaningless rants, I suggest you do it someplace else instead
    of wasting everyone's time here.

    Cheers
    Ken

    "clintonG" <> wrote in message
    news:...
    : This really aggravates the hell out of me. My server is (-06:00 GMT) and
    the
    : 2.0 Website Administration Tool for example and other 2.0 controls write
    : database entries offset 6 hours into the future. So William, when you mean
    : "adjust" you must mean the database administrator or the web developer
    must
    : "adjust" to the fact that they are now compelled to write compensation
    code
    : that somehow captures the date and time of the user and applies an offset
    to
    : accurately record date and time circumstantially.
    :
    : The flaw in this reasoning, and correct me if I'm wrong, is the fact that
    : the framework does not record which time zone a user is in when it
    : automatically records the date and time using "adjusted" GMT values which
    : requires the use of an offset. So how is the database administrator or the
    : developer supposed to know what offset value to use when they need to work
    : with the date and time values at some point in the future?
    :
    : As far as I've been able to determine the answer is "they don't." This
    : decision by some Microsoft crackhead to force everybody to record data
    using
    : GMT was not thought out well and as usual implemented as crippleware.
    :
    : If we are going to be forced to adopt GMT at least the offset value should
    : be recorded into the database when the framework uses brute force to
    record
    : the GMT value.
    :
    : <%= Clinton Gallagher
    : METROmilwaukee (sm) "A Regional Information Service"
    : NET csgallagher AT metromilwaukee.com
    : URL http://metromilwaukee.com/
    : URL http://clintongallagher.metromilwaukee.com/
    :
    :
    :
    : "William (Bill) Vaughn" <> wrote in message
    : news:%...
    : > We don't use local time for situations like this. We use GMT. This way
    : > it's always the same world-wide. Once captured we can query the local
    : > system for its current timezone and adjust--but only if the user has to
    : > see this value and it must be shown in the local timezone.
    : >
    : > --
    : > ____________________________________
    : > William (Bill) Vaughn
    : > Author, Mentor, Consultant
    : > Microsoft MVP
    : > INETA Speaker
    : > www.betav.com/blog/billva
    : > www.betav.com
    : > Please reply only to the newsgroup so that others can benefit.
    : > This posting is provided "AS IS" with no warranties, and confers no
    : > rights.
    : > __________________________________
    : >
    : > "Nathan Sokalski" <> wrote in message
    : > news:%...
    : >>I use a webhosting service that is something like halfway around the
    world
    : >>from me and most of the people that will be viewing my site (and I am
    : >>assuming their server is too). This obviously has very little effect on
    : >>what I can do, but there is one thing that I would like to know how to
    do
    : >>(if it can be done). When I do something that involves getting the
    current
    : >>date or time, my application gets it from the server it is running on,
    : >>which means it could be off by as much about half a day, and many of my
    : >>pages preselect the current date for certain things, but sometimes that
    is
    : >>incorrect for the same reason. Is there any way to make my entire
    : >>application automatically adjust these values to the timezone I am in
    (is
    : >>there a way I can put a setting in the web.config or Global.asax.vb file
    : >>or something that says "where I am" so it adjusts these values based on
    : >>where the server says it is)? This would make things much less
    complicated
    : >>for me, as well as make it easier if I ever have to move my application
    to
    : >>a different webhost or server. Thanks.
    : >> --
    : >> Nathan Sokalski
    : >>
    : >> http://www.nathansokalski.com/
    : >>
    : >
    : >
    :
    :
     
    Ken Schaefer, Jan 23, 2006
    #8
  9. Nathan Sokalski

    Ken Schaefer Guest

    Nathan,

    I may be misunderstanding your issue here, but are you saying:
    a) you attempt to get the current date/time using .NET code running on the
    server
    b) the date/time you get in (a) above reflects the date/time on the server
    c) but you yourself (and your browser) are located in a completely different
    timezone
    d) as a result of (b) and (c) the date/time on the server doesn't reflect
    the date/time where you yourself are sitting?

    The problem here is that the server has no idea where you are, or what
    timezone you are in. You'd probably need to ask each user what their current
    timezone is, and then have your code apply an offset to display the time
    according to the user's current timezone.

    Cheers
    Ken


    "Nathan Sokalski" <> wrote in message
    news:%...
    :I use a webhosting service that is something like halfway around the world
    : from me and most of the people that will be viewing my site (and I am
    : assuming their server is too). This obviously has very little effect on
    what
    : I can do, but there is one thing that I would like to know how to do (if
    it
    : can be done). When I do something that involves getting the current date
    or
    : time, my application gets it from the server it is running on, which means
    : it could be off by as much about half a day, and many of my pages
    preselect
    : the current date for certain things, but sometimes that is incorrect for
    the
    : same reason. Is there any way to make my entire application automatically
    : adjust these values to the timezone I am in (is there a way I can put a
    : setting in the web.config or Global.asax.vb file or something that says
    : "where I am" so it adjusts these values based on where the server says it
    : is)? This would make things much less complicated for me, as well as make
    it
    : easier if I ever have to move my application to a different webhost or
    : server. Thanks.
    : --
    : Nathan Sokalski
    :
    : http://www.nathansokalski.com/
    :
    :
     
    Ken Schaefer, Jan 23, 2006
    #9
    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. Veerle
    Replies:
    3
    Views:
    838
    Phil...
    Oct 24, 2003
  2. Replies:
    1
    Views:
    333
    Oliver Wong
    Aug 31, 2006
  3. Eric Wertman

    time module question - time zones

    Eric Wertman, May 21, 2008, in forum: Python
    Replies:
    0
    Views:
    502
    Eric Wertman
    May 21, 2008
  4. Frank Cisco
    Replies:
    0
    Views:
    344
    Frank Cisco
    Jun 1, 2009
  5. Replies:
    2
    Views:
    113
Loading...

Share This Page