Dave Turner <no****@nowhere.nohow> wrote:
Can PHP get the current GMT time and add an hour to it? for example i think
See gmdate in the manual
Japan is GMT +8 so would it be possible to write a PHP script to show the
current time in Japan based on that?
Japan is at +9 at this moment in time (but that can change in the future
(or past)). Don't count on absolute offsets.
It's has been asked before (many times):
$ php4 /tmp/tz.php
GMT : Thu, 07 Apr 2005 19:17:14 +0000
Local: Thu, 07 Apr 2005 21:17:14 +0200
Tokyo: Fri, 08 Apr 2005 04:17:14 +0900
The source:
<?php
$now=time();
echo "GMT : ".gmdate('r',$now)."\n";
echo "Local: ".date('r',$now)."\n";
putenv("TZ=Asia/Tokyo");
echo "Tokyo: ".date('r',$now)."\n";
?>