In php, is there a way to set default timezone in .htaccess or wherever, as long as i don have to set it at every php page.
provided i don have access to server, only PHP files. Thanks in advance
UPDATE
i am using apache (LAMP), and don't have access to php.ini
If the server is properly configured and you want to set your process time-zone to this server value (if not set), then in the doc-root
.htaccess
you can set a PHP file to run before any other PHP file -and in this file you can define a couple of configurations, functions and classes to use as "tools" which will be available in all the other PHP files - like this:.htaccess
path/of/file.php
I was getting 500 (Internal server Error) using the code
php_value date.timezone "Europe/Berlin"
.Then I tried,
SetEnv TZ Australia/Melbourne
and it worked like a charm.Set
date.timezone
in your php.ini. Supported timezone values: http://php.net/manual/en/timezones.phpConsidering you use apache from the fact you mention .htaccess:
Yes, as long as it runs mod_php it is possible in .htaccess like so:
Or you could set date.timezone in php.ini like Karl Laurentius Roos suggested. This would only be possible if you have access to your php config through. Remember to restart PHP (CGI mode) or your webserver (mod_php) after altering php.ini.
If you get a 500 error you might try checking for the PHP5 module, works for me.
After adding below code in .htaccess file from CPanel Server.
I used to get 500 (Internal server Error)
Then I navigated to the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor) >> Edit PHP INI settings
OR
Go to the Path /homecws/Your_folder_name/public_html/php.ini then include
date.timezone=Asia/Kolkata
in php.ini fileHere is the complete php.ini file
This solved and worked for mine.