Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.6: Set default time zone for PHP in Snow Leopard UNIX
It seems like the new PHP version in Snow Leopard wants you to explicitly set a default timezone when calculating stuff using the date() function, and will warn you about this in your script's output.

To set the date, look in /etc and find php.ini.default, open it up in your favorite editor (BBEdit work great, but sudo pico /etc/php.ini.default works as well). Look for this line:
date.timezone = 
Add your preferred timezone, like so:
date.timezone = "Europe/Berlin"
Read this page in the PHP manual for supported zones and cities.

After you're done with that, rename the file using sudo mv php.ini.default php.ini and restart your computer to implement the time zone change.
    •    
  • Currently 2.67 / 5
  You rated: 2 / 5 (15 votes cast)
 
[29,485 views]  

10.6: Set default time zone for PHP in Snow Leopard | 5 comments | Create New Account
Click here to return to the '10.6: Set default time zone for PHP in Snow Leopard' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Set default time zone for PHP in Snow Leopard
Authored by: osxboy on Sep 08, '09 07:46:33AM
to avoid this step:
After you're done with that, rename the file using sudo mv php.ini.default php.ini and restart your computer to implement the time zone change.
Either go to SystemPreferences/Sharing and toggle 'Personal Web Shaing' off and on again or open a Terminal window and type: sudo /usr/sbin/apachectl graceful

[ Reply to This | # ]
10.6: Set default time zone for PHP in Snow Leopard
Authored by: schutt on Sep 08, '09 10:39:21AM
It is better to first copy the file from /etc/php.ini.default to /etc/php.ini before editing it. This way you always have the default in case you make a mistake. The default (at least on my computer) has the timezone line commented out with a ";", so don't forget to remove the ";" if you want to actually change it.

[ Reply to This | # ]
10.6: Set default time zone for PHP in Snow Leopard
Authored by: 5chm31din6 on Sep 08, '09 11:37:42PM

I followed these instructions to the letter (I'm no *ini / *.conf slouch), but it's still not working for me.

date.timezone is still "no value" in the phpinfo() output.

Any ideas? Thanks in advance.

---
Power corrupts. PowerPoint corrupts absolutely.

[ Reply to This | # ]

10.6: Set default time zone for PHP in Snow Leopard
Authored by: schutt on Sep 10, '09 08:06:07AM

I disabled web sharing, made the changes, then enabled it again without restarting. It worked.

Did you remove the ";" at the beginning of the line? Do you have two versions of PHP installed?



[ Reply to This | # ]
10.6: Set default time zone for PHP in Snow Leopard
Authored by: mcilvena on Feb 16, '10 08:18:09PM
I was having issues getting this to work, so I removed the quotes which fixed the problem.

[Date]
; Defines the default timezone used by the date functions
date.timezone = Australia/Melbourne


[ Reply to This | # ]