Setting timezone globally

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
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

Setting timezone globally

Post by edawson003 »

I would like to set my timezone globally for a certain directory. I read somewhere that the syntax to add to my php.ini to affect timezone globally is
;date.timezone =Asia/Jakarta
. I tried it, but it didn't work. Am I not using the right syntax.

In the meantime, I am able to affect timezon on a page by page basis by applying:

Code: Select all

<?
ini_set('date.timezone', 'America/Los_Angeles');
?>
I have a form where I ask visitors to identify their timezone. Is there a way to customize date for affected users based on the timezone they specified?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Setting timezone globally

Post by John Cartwright »

You can modify the PHP timezones settings in php with SetEnv.

I.e. (.htaccess)
SetEnv TZ America/Montreal
Note however, this does NOT affected mysql datetime settings.
Post Reply