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

    What does:

    <?php
    
    echo date('r');
    
    echo "<br><br>";
    
    echo gmdate('r');
    
    ?>

    get you?

      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

        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. [man]date/man, 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, [man]gmdate/man 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?

          I'm using Redhat 8.
          Where is the time zone config file located?
          Is it in the "/etc" folder? 🙂

            Zones are in /usr/share/zoneinfo and your local time is in /etc/localtime. You should symlink to the correct one.
            ie. [font=courier]ln -sf /etc/localtime /usr/share/zoneinfo/HongKong[/font]

              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 🙂

                Write a Reply...