I am running a website on a server in a different country and need to use the current time and date a lot - converting to GMT and back to the local time of the viewers who are as such in a different country.
The server is running RH Linux 7.3 and PHP 4.12
as a test i run this code:
echo setlocale(LC_TIME,NULL);
echo ":<br>";
echo date("H:i:s O (I)")."<br>\n";
echo gmdate("H:i:s O (I)")."<br>\n";
echo setlocale (LC_TIME, 'en_US');
echo ":<br>";
echo date("H:i:s O (I)")."<br>\n";
echo gmdate("H:i:s O (I)")."<br>\n";
echo setlocale (LC_TIME, 'en_AU');
echo ":<br>";
echo date("H:i:s O (I)")."<br>\n";
echo gmdate("H:i:s O (I)")."<br>\n";
and this is the output it get:
C:
08:40:24 -0400 (1)
12:40:24 +0000 (0)
en_US:
08:40:24 -0400 (1)
12:40:24 +0000 (0)
en_AU:
08:40:24 -0400 (1)
12:40:24 +0000 (0)
for starters the GMT date is wrong! daylight savings is on in the servers location and thus the difference between GMT and local time should NOT be 4 hours. The GMT wrong by 1 hour!
Second when i set the locale to en_AU (my locale ~ GMT +1000) it accepts the change but doesnt format the date. Is there any way to fix this. I have access to change almost everything on the virtual server except set the hardware time; i can ssh into the server.
We are hoping to make the website international later too so we want to always use the local time for the user, whichever country they might be in, and i would rather not have to try and manually add hours to the returned date as this would get very messy if we had users all over the world.
Has anyone ever used setlocale() to display the date?