Time zones: Pretending to be somewhere else

N

Nathan Sokalski

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.
 
N

Nathan Sokalski

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?
 
E

EJD

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
 
W

William \(Bill\) Vaughn

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.
__________________________________
 
C

clintonG

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/
 
D

David Wang [Msft]

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.
//
 
K

Ken Schaefer

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

: 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/
:
:
:
: : > 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.
: > __________________________________
: >
: > : >>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
: >> (e-mail address removed)
: >> http://www.nathansokalski.com/
: >>
: >
: >
:
:
 
K

Ken Schaefer

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


: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
: (e-mail address removed)
: http://www.nathansokalski.com/
:
:
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top