PDA

View Full Version : new server == weird issues with php and date


dang
04-04-2005, 08:07 AM
Ok, so our raid degraded on Friday and we had to get a new server.

One weird thing going on: the server was set to CDT when we got it. I changed it to PDT, and running date from the shell shows PDT, but PHP still thinks its CDT. I can't for the life of me get it to show the correct time zone.

I've tried switching timezone to UTC, EDT, etc and php still shows CDT.

To show the timezone in php, i'm just running:
<?php
$time = date("T");
echo $time;
?>

It's weird, anyone else seen this before?

dang
04-04-2005, 08:15 AM
Ok, an apache restart did not fix, but a server reboot did. That is weird. A server reboot should never be needed to clear up an issue like this. Thankfully it's a one time thing.

spankers
04-04-2005, 08:20 AM
It's probably a hardware clock/system clock thing. Having to reboot to reconfigure TZ sucks though.

llbbl
04-04-2005, 10:49 AM
Setting your time zone
In /etc the file, localtime, is a link to or copy of a file containing information about your time zone. Zone information files are usually in /usr/share/zoneinfo but this depends on your distribution. So if your localtime file points to a zone info file that is not your time zone you can change it by browsing the directories in /usr/share/zoneinfo to find your country, then find your city or a city in the same time zone and link localtime to it.

$ ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

http://hypexr.org/tips.shtml

Or you can use one of the following programs to setup a NTP service to automatically update the clock for you.

RDATE
http://freshmeat.net/projects/rdate/

NTP
http://freshmeat.net/projects/ntp/

CHRONY
http://freshmeat.net/projects/chrony/

Red Hat has a set Time/Date GUI that has an option for NTP protocol so you can set it without the command line.

dang
04-04-2005, 01:48 PM
thanks tecknogeek. I know NTP is not running by default.

We do not run xwindows on the box as this is a pure server box remotely administered.

spankers
04-04-2005, 01:49 PM
Or you can hook up a GPS receiver to your box and become a Stratum 1 time source... and avoid any latency issues if you need millisecond precision.

spankers
04-04-2005, 01:53 PM
We do not run xwindows on the box as this is a pure server box remotely administered.

You could always allow remote X apps...
How about a shell account, dang? ;)

llbbl
04-05-2005, 09:48 AM
Stratum 1 time source

hmm whats taht.

A device that is synchronized to a Stratum 0 reference time clock is referred to as a "Stratum 1" source. It is typically attached to the directly synchronized clock via radio, GPS or portable atomic clock. The stratum 1 device answers queries from other devices that request its time information. This device can be configured to use other sources if its primary reference (from the Stratum 0 clock) fails in some manner.

http://tns.its.psu.edu/services/networking/ntp.html


The radio solution would be cheaper thou right. Like those radios that recieve the NIST signal, maybe you could take one of those apart and hook it up to your computer :)