Web Hosting Talk







View Full Version : server's time zone


Abu Mami
05-27-2002, 12:53 PM
Where is the server's time zone defined? When I check it using this PHP code:
$serveroffset = (int) date("Z") / (60 * 60);
I get the value -7. My server is sitting in Calif. First off, shouldn't the value be -8?

How is the time zone defined? How can I change it? Any help will be greatly appreciated? I need this urgently.

Thanks.

RutRow
05-27-2002, 01:15 PM
Originally posted by Abu Mami
How is the time zone defined? How can I change it?

Depends on what you are running.

For a RedHat box, time zone is stored in /etc/localtime and you can set it using timeconfig.

Abu Mami
05-27-2002, 01:32 PM
Originally posted by RutRow
For a RedHat box, time zone is stored in /etc/localtime and you can set it using timeconfig. Great! Thanks. I'll check this out.

CagedTornado
05-28-2002, 01:14 AM
On a linux box, /etc/timezone is usually linked to a 'zonefile' under /usr/share/zoneinfo.

Dan

priyadi
05-28-2002, 01:36 AM
FYI, it is possible to change timezone per user basis: http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_431.html

With PHP Apache module, it should be possible to set that by using SetEnv in .htaccess. Never tried that though.

iamdave
05-28-2002, 03:47 AM
timeconfig US/Pacific

RutRow
05-28-2002, 09:20 AM
Originally posted by CagedTornado
On a linux box, /etc/timezone is usually linked to a 'zonefile' under /usr/share/zoneinfo.

Dan

This may be true for some flavors of Linux, but not for a recent RedHat version. From the man page:

/etc/localtime File containing timezone data, copied from /usr/share/zoneinfo.

Abu Mami
05-28-2002, 12:32 PM
Thanks again to everyone for the comments. I made a fix by just hard-coding the time zone right into my script. Not elegant, but it works, and it really doesn't matter since the script is only intended to run on my box. If I can ever find some free time, I'll try to do it "right".

CagedTornado
05-29-2002, 11:32 AM
Originally posted by RutRow


This may be true for some flavors of Linux, but not for a recent RedHat version. From the man page:

/etc/localtime File containing timezone data, copied from /usr/share/zoneinfo.


DOH! I apologize. You are so correct. Thank you for correcting my mistake.

Dan

webx
05-30-2002, 04:42 PM
Just wanted to add that on FreeBSD, you can use tzsetup :) Took sometime for me to find out the first time, hope it will save some time for someone else ;)