Connecting Tech Pros Worldwide Forums | Help | Site Map

Time Zone...

Ima Lostsoul
Guest
 
Posts: n/a
#1: Jul 17 '05
My server is set to GMT which I cannot change. Using PHP I need to be
able to pull the current date for a given time zone and display it on
the page when a user loads it. The time zone does not need to be
specific to the user. It can be set to (in this case) Eastern time. I
would like it to be able to take care of DST on its own as well. Can
someone tell me how to do this please?

Warren Oates
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Time Zone...


In article <MPG.1bee176591e7556a98972f@netnews.comcast.net> ,
Ima Lostsoul <nospam@ugabuggaboo.org> wrote:

:My server is set to GMT which I cannot change. Using PHP I need to be
:able to pull the current date for a given time zone and display it on
:the page when a user loads it. The time zone does not need to be
:specific to the user. It can be set to (in this case) Eastern time. I
:would like it to be able to take care of DST on its own as well. Can
:someone tell me how to do this please?

putenv(TZ="America/Montreal");

should put your script in the Eastern timezone. I use this: my server is
in the central zone.

http://ca.php.net/manual/en/function.putenv.php
--
Looks like more of Texas to me.
.... Arizona, where the nights are warm and the roads are straight.
Cecile Muller
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Time Zone...


> My server is set to GMT which I cannot change. Using PHP I need to be[color=blue]
> able to pull the current date for a given time zone and display it on
> the page when a user loads it. The time zone does not need to be
> specific to the user. It can be set to (in this case) Eastern time. I
> would like it to be able to take care of DST on its own as well. Can
> someone tell me how to do this please?[/color]

This may be helpful:
http://downloads.wildpeaks.com/RR/timezones.php.txt
It was meant to alow the user to change the timezone in which he wants
to display the page, just remove the form as your script sets the
timezone itself.
TJ Talluto
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Time Zone...


If you're lucky, your db will support session based timezone changes like
this:

$sql = "set TIME ZONE 'EDT4EST' ";

Now you've set the timezone on the database for ONLY the session of this
user. Other user sessions are NOT affected. Now when you retrieve a
timestamp from your database, the database will already present it to this
user in EST (and it also already knows if you are on EST or EDT, and makes
the one hour offset automatically if necessary !). Slick!

--
TJ Talluto
torpedo51 at yahoo dot com
TJ Talluto
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Time Zone...


Warren Oates wrote:
[color=blue]
> putenv(TZ="America/Montreal");
>
> should put your script in the Eastern timezone. I use this: my server is
> in the central zone.[/color]

As you stated, this will set your server in that timezone. This is
acceptable for you, but VERY undesirable for any of you other readers who
have users in several timezones, or your database supports multiple
timezones. If that is true, then set your database to UTC, and use session
based timezone settings so that users can work independently (as my earlier
posting describes). The payoff is that you NEVER have to perform date math
on your client or application... the database does it all.


--
TJ Talluto
torpedo51 at yahoo dot com
Warren Oates
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Time Zone...


In article <4Oxhd.30909$hN1.13001@twister.socal.rr.com>,
TJ Talluto <tj@getlostspammers.com> wrote:

:As you stated, this will set your server in that timezone. This is
:acceptable for you, but VERY undesirable for any of you other readers who
:have users in several timezones, or your database supports multiple
:timezones.

But the OP specifically asked in
<MPG.1bee176591e7556a98972f@netnews.comcast.net> :
:Using PHP I need to be
:able to pull the current date for a given time zone and display it on
:the page when a user loads it. The time zone does not need to be
:specific to the user. It can be set to (in this case) Eastern time.
--
Looks like more of Texas to me.
.... Arizona, where the nights are warm and the roads are straight.
Closed Thread