Page 1 of 1
Correct time...
Posted: Sat Aug 24, 2002 2:35 am
by Cyphonic
My site is hosted on a server in canada or something, and the time in Norway (where I live) is 2 hours ahead of the time in Canada! So how can i get the server to display the correct time, when the format is like this:
$time = date ("H:i:s");
Posted: Sat Aug 24, 2002 3:02 am
by Takuma
Easy get the number of hours and add on 2!
Posted: Sat Aug 24, 2002 8:29 am
by daemorhedron
One method would be to simply do
$time = date ("H:i:s",time()+7200);
//format the date of the current time+2 hours
or you could look into gmdate().
HTH =)
Posted: Sat Aug 24, 2002 10:27 am
by 9902468
Takuma's approach is not good, since (as everyone knows, this was a joke?) if you always add 2 hours to hour you can get time like 25:43:12....
Just pointed out that so nobody really uses that. Use daemorhedron's method: works always and is more efficient.
-9902468
Posted: Sat Aug 24, 2002 11:26 am
by volka
localtime() user contributed notes
to set up berlin time it could look like this:
<?php
print "<HTML><body><pre>";
setlocale( "LC_ALL", "de_DE" );
putenv( "PHP_TZ=Europe/Berlin" );
$now = time();
print_r( localtime(time(),true) );
print_r( getdate() );
print date("H:i:s");
print date("T");
?>
Posted: Sat Aug 24, 2002 2:33 pm
by Takuma
Oops... Sorry for the bad help... I should have thought more...
Volka can you tell me what's going on with your script cos I'm not following it. Thanks
Posted: Sat Aug 24, 2002 3:02 pm
by volka
it's setting the 'locals'-settings (number format, type of calendar,...) to german default and sets the timezone to Europe/Berlin (GMT+1 ?)
Didn't know the enviroment-var was 'PHP_TZ' - just a quotation from the user contributed notes

Posted: Sat Aug 24, 2002 3:57 pm
by Takuma
Thanks Volka but do you know where I can find out list of things like "de_DE" for different country? e.g. I want to know USA and Japan.
Posted: Sat Aug 24, 2002 4:58 pm
by volka
gosh, I like the online manual

Posted: Sun Aug 25, 2002 12:21 am
by Takuma
Thanks.
