Click to See Complete Forum and Search --> : gmdate() return wrong time zone


wtleung7
06-18-2004, 01:18 PM
Hi,

I'm running php 4.3.2 on redhat linux.

This is the output when I type linux command 'date':

Sat Jun 19 00:15:08 GMT+8 2004

This is the correct local time and I'm in HK (GMT +8).

However if I call gmdate() in PHP, it returns

Jun 19 2004 08:17:03

This is incorrect because I expect it to be 8 hours less than my local time.

Any idea on this issue? Is it the problem on my linux configuration?

Thank you very much.

Regards,
Raymond

dalecosp
06-22-2004, 02:08 AM
What does:<?php

echo date('r');

echo "<br><br>";

echo gmdate('r');

?>get you?

wtleung7
06-25-2004, 07:34 AM
Thanks for your help first, dalecosp.

Here is the output of your suggested script.

// echo date('r');
Fri, 25 Jun 2004 18:27:34 -0800
// The above time is the correct local time in hong kong



// echo gmdate('r');
Sat, 26 Jun 2004 02:27:34 +0000
// The above one is incorrect because I'm in HK (GMT+8), gmdate() should return a time with 8 hours less than my local time


Regards,
Raymond

dalecosp
06-25-2004, 04:20 PM
Well, you're welcome ... I hope I can be of some assistance.

It sure does appear as if the system you are working on has the wrong time. date(), to the best of my knowledge, is actually returning an Alaskan TZ on this side of the IDL (- 0800) instead of Hong Kong time on that side (+ 0800).

So, gmdate() is actually behaving correctly. Your system has been "rigged" to appear as if the local time is correct, but I'd guess that it really isn't.... :(

If you can get my script to output the correct local time with "+ 0800" from date(), then gmdate() should also be correct. What (operating) system is it?

wtleung7
06-26-2004, 05:11 AM
I'm using Redhat 8.
Where is the time zone config file located?
Is it in the "/etc" folder? :)

LordShryku
06-26-2004, 01:52 PM
Zones are in /usr/share/zoneinfo and your local time is in /etc/localtime. You should symlink to the correct one.
ie. ln -sf /etc/localtime /usr/share/zoneinfo/HongKong

wtleung7
06-28-2004, 02:07 PM
Here is the output of "ls -l | grep time" in /etc/

-rw-r--r-- 1 root root 48 Jun 14 02:52 adjtime
-rw-r--r-- 1 root root 58 Mar 23 2003 localtime

It's a physical file rather than a symbolic link to /usr/share/zoneinfo/Hongkong

Before creating a symbolic link by
"ln -sf /etc/localtime /usr/share/zoneinfo/HongKong",
I would like to backup the original file first. And I want to ask about the command of removing symbolic link, how to remove the symbolic link if I want to rollback?


Thanks.


Regards,
Raymond :)

LordShryku
06-28-2004, 03:49 PM
rm linkname