Re: Date problem
- From: "Charles Lavin" <x@xxx>
- Date: Tue, 28 Jul 2009 03:58:31 -0400
2/. Use javascript to pick up the local timezone on their machine and
adjust the displayed result accordingly.
This is where I fog up. If a JavaScript function determines the local time
zone, and the PHP page is essentially hardcoding server-local times into the
page the browser is about to display, isn't it too late to do anything with
the JavaScript routine?
Like I said: I'll do the math myself on the PHP side ... But I need to get
that local time zone down to the server somehow ...
And I think I'm beginning to see the light ... and not just because the sun
is almost ready to rise ...
CL
"The Natural Philosopher" <tnp@xxxxxxxxxxxxxxx> wrote in message
news:h4m9rm$ltf$1@xxxxxxxxxxxxxxxxxxxx
Charles Lavin wrote:
Don't crosspost what? The original message was posted to comp.lang.php.You have two, maybe three possibilities.
I have a Web site that's hosted on a server three time zones west of
here.
I have users who are located in this time zone and in time zones
immediately east and west of here.
So any time displayed by the server -- be it current time or a file
timestamp -- is going to be either two, three or four hours off.
The biggest problem I have is with the early hours of the morning, when
the server is seemingly a day behind -- i.e. at 2 a.m. on 7/28/09 here,
the server is reporting that it's 7/27/09. One particular page
dynamically builds a link, in which the current date is embedded, to
another server out here. So for several hours in the morning, that link
winds up pointing to the wrong page.
Another source of confusion is the display of file timestamps that are
local to the server, which cause users to think that files are older than
they really are.
I don't really want to have to ask the user what time zone (s)he is in,
because I'm sure that at least a few of them won't know how to answer the
question. I do know that the _computer_ knows what time zone it's in.
Isn't there a way for the server to query this information from the
client?
And if PHP doesn't have a function to automatically perform the time
offset based on the client's time zone, I'll gladly do the math myself. I
just need to know how to get the necessary information.
Thanks
CL
"C. (http://symcbean.blogspot.com/)" <colin.mckinnon@xxxxxxxxx> wrote in
message
news:6cd71aa5-e87e-4da2-b526-015cd8d5abb3@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jul 23, 8:17 am, JC <ja...@xxxxxxxxxxxxxxxxxxx> wrote:
Unless you want to do clever IP location on the server to find the
time zone of the client, javascript is the only way.
On Jul 23, 7:01 am, "Charles Lavin" <x...@xxx> wrote:
I'm having a problem with dates that I can't seem to find a solution to
...
How do I get a Web page to display the current date (and time) OF MY
BROWSER
on the page?
First, please don't crosspost.
The OP hasn't explained their problem very clearly - but then if
Charles understood the right questions to ask, he probably would have
known how to find the answers.
As far as I am aware, the browser does not notify the server what
locale they are in, nor, specifically, what timezone. However if he
really wants to show the the time appropriate to the timezone of the
browser, then he could set up a javascript program to automatically
report back to the server what the local time at the browser is -
then, allowing for clock drift, it would be possible to estimate the
timezone offset and push this back to the browser as a cookie or store
it in the session. Alternatively he could just ask the user what
timezone they are in.
Having got this information, it would then be possible to calculate
the user's local time and write this to the browser (RTFM for
date_timezone_set()) - unless (see below) he has a specific
requirement to report the server's time translated to the browsers
timezone, it would be a lot simpler just to use Javascript.
OTOH, if he wants to report time very accurately, then he should be
hooking his server into an upstream NTP provider and running a clock
synchronization / drift analysis daemon (e.g. xntpd) then following
the steps above to get the local time at the browser.
C.
1/. work out from senders IP address where he/she is. And apply that.
Which is nasty, as it's noty guaranteed to give a meaningful answer, and
they may be using a remote web proxy.
2/. Use javascript to pick up the local timezone on their machine and
adjust the displayed result accordingly.
3/. do the whole thing in GMT, and write a note ...telling them.
Of these, javascript is the best solution. it has a function that returns
offset from GMT.
.
- Follow-Ups:
- Re: Date problem
- From: Scott Johnson
- Re: Date problem
- From: Captain Paralytic
- Re: Date problem
- References:
- Date problem
- From: Charles Lavin
- Re: Date problem
- From: JC
- Re: Date problem
- From: C. (http://symcbean.blogspot.com/)
- Re: Date problem
- From: Charles Lavin
- Re: Date problem
- From: The Natural Philosopher
- Date problem
- Prev by Date: Re: Date problem
- Next by Date: Re: ** Even Jerks can't make money online
- Previous by thread: Re: Date problem
- Next by thread: Re: Date problem
- Index(es):
Relevant Pages
|
Loading