Time offsets

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Craig
Forum Commoner
Posts: 37
Joined: Thu Apr 18, 2002 3:13 pm

Time offsets

Post 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?
Craig
Forum Commoner
Posts: 37
Joined: Thu Apr 18, 2002 3:13 pm

Post by Craig »

sorry, just a bump, people may have missed this :oops:
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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?
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post by sam »

Code: Select all

$t_stamp = time();
$t_stamp  -= (5 * 3600);
echo date("h:m:s",$t_stamp);
Cheers Sam
Craig
Forum Commoner
Posts: 37
Joined: Thu Apr 18, 2002 3:13 pm

Post by Craig »

Perfect Sam, that'll do nicely


Cheers
Post Reply