473,387 Members | 1,520 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,387 software developers and data experts.

Time zones: Pretending to be somewhere else

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
nj********@hotmail.com
http://www.nathansokalski.com/
Jan 21 '06 #1
8 1223
EJD
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

Jan 21 '06 #2
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
nj********@hotmail.com
http://www.nathansokalski.com/

"EJD" <jp******@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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

Jan 21 '06 #3
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

Jan 21 '06 #4
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" <nj********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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
nj********@hotmail.com
http://www.nathansokalski.com/

Jan 21 '06 #5
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" <bi**************@nwlink.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <nj********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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
nj********@hotmail.com
http://www.nathansokalski.com/


Jan 21 '06 #6
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" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Of**************@TK2MSFTNGP15.phx.gbl...
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" <bi**************@nwlink.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <nj********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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
nj********@hotmail.com
http://www.nathansokalski.com/



Jan 22 '06 #7
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" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Of**************@TK2MSFTNGP15.phx.gbl...
: 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" <bi**************@nwlink.com> wrote in message
: news:%2****************@TK2MSFTNGP10.phx.gbl...
: > 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" <nj********@hotmail.com> wrote in message
: > news:%2****************@TK2MSFTNGP14.phx.gbl...
: >>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
: >> nj********@hotmail.com
: >> http://www.nathansokalski.com/
: >>
: >
: >
:
:
Jan 23 '06 #8
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" <nj********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
: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
: nj********@hotmail.com
: http://www.nathansokalski.com/
:
:
Jan 23 '06 #9

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...
8
by: Nathan Sokalski | last post by:
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...
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...
6
by: jehugaleahsa | last post by:
Hello: I would like it so that the time displayed was always for CDT/CDS. Potentially, the application can be run at locations in Mountain Time or Central Time. This is what I have now: //...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.