PHP date_default_timezone_set ()

In php, is there a way to set the default time zone in .htaccess or anywhere if I need to set it on every php page.

if I have access to the server, only PHP files. thanks in advance

UPDATE

I am using apache (LAMP) and do not have access to php.ini

+7
source share
4 answers

Given that you are using apache from what you mention .htaccess:

Yes, as long as it runs mod_php, this is possible in .htaccess as follows:

php_value date.timezone "Europe/Berlin" 

Or you can set date.timezone in php.ini, as suggested by Karl Lavrenti Ruos. This would only be possible if you have access to your php configuration. Remember to restart PHP (CGI mode) or your web server (mod_php) after changing php.ini.

+11
source

Set date.timezone to your php.ini. Supported time zone values: http://php.net/manual/en/timezones.php

+3
source

I was getting 500 (Internal server error) using code

php_value date.timezone "Europe/Berlin" .

Then I tried SetEnv TZ Australia/Melbourne and worked like a charm.

+2
source

If you get a 500 error, you can try checking the PHP5 module, works for me.

 <IfModule mod_php5.c> php_value date.timezone "Europe/Lisbon" </IfModule> 
0
source

All Articles