Page 1 of 1

Time offsets

Posted: Fri Apr 19, 2002 3:07 am
by Craig
Is there an easy way to set up time to take into account timezone differences?

I have webspace hosted in Canada, but I live in the uk so the timezone is out by 7 hours I think it is.

I can't find any tutorials on working with timezones, ideally I'd like to be able to set up something to print the time and have it adjusted by a single variable.

I noted on my local machine(Apache on Win 98) that this worked:

Code: Select all

$h = date("H")-5;
$time = date("$h.i");

But that didn't work when on the server (Apache on linux) :(

Can anyone point me in the right direction of a solution?

Posted: Fri Apr 19, 2002 2:55 pm
by Craig
sorry, just a bump, people may have missed this :oops:

Posted: Fri Apr 19, 2002 3:04 pm
by jason
I never had to worry about this, however, you might try something using the setlocale() function, and work with the gmdate() function. Might be useful?

Posted: Fri Apr 19, 2002 4:04 pm
by sam

Code: Select all

$t_stamp = time();
$t_stamp  -= (5 * 3600);
echo date("h:m:s",$t_stamp);
Cheers Sam

Posted: Sun Apr 21, 2002 3:48 pm
by Craig
Perfect Sam, that'll do nicely


Cheers