roguitar Posted August 25, 2019 Posted August 25, 2019 Is there any way of changing the server time zone? I want data to be recorded within my local time zone. And by the way, you use UTC, right?
BlueyEmperor Posted August 25, 2019 Posted August 25, 2019 Is there any way of changing the server time zone? I want data to be recorded within my local time zone. And by the way, you use UTC, right?It is set to UTC and I believe the time zone is unchangeable.
Sn1F3rt Posted August 25, 2019 Posted August 25, 2019 It's not possible to change the timezone specifically for your account as it is a root function and is set through WHM. However, if you're looking for the changes to the on your website (ie, data to be displayed in your timezone) this might be helpful: https://www.interserver.net/tips/kb/change-default-timezone-using-htaccess-cpanel/ .
roguitar Posted August 25, 2019 Author Posted August 25, 2019 It's not possible to change the timezone specifically for your account as it is a root function and is set through WHM. However, if you're looking for the changes to the on your website (ie, data to be displayed in your timezone) this might be helpful: https://www.interserver.net/tips/kb/change-default-timezone-using-htaccess-cpanel/ .Well, I've set it to: SetEnv TZ America/Sao_Paulo And nothing happened.
Sn1F3rt Posted August 25, 2019 Posted August 25, 2019 Wait sometime... It takes time for changes to take place. Also changes will take place only in your website and but in cPanel as such.
Piotr GRD Posted August 25, 2019 Posted August 25, 2019 Making changes in .htaccess file (no matter if trough file manager in cPanel or trough FTP) have instant effect (unless there is some cache in your browser for example). I don't remember since which version of PHP exactly (5.x), but while in older versions setting value of an environment variable "TZ" worked fine, in newer versions you have to use date_default_timezone_set, variable "TZ" won't change anything for you. # For older PHP versions (up to 5.2 or 5.3): # - in PHP script: <?php putenv("TZ=UTC"); ?> # - in .htaccess: SetEnv TZ UTC # For newer versions of PHP (function exists since 5.1, but required since 5.4 or so): # - in PHP script: <?php date_default_timezone_set('UTC'); ?> # - in .htaccess: php_value date.timezone 'UTC'
roguitar Posted August 25, 2019 Author Posted August 25, 2019 (edited) Making changes in .htaccess file (no matter if trough file manager in cPanel or trough FTP) have instant effect (unless there is some cache in your browser for example). I don't remember since which version of PHP exactly (5.x), but while in older versions setting value of an environment variable "TZ" worked fine, in newer versions you have to use date_default_timezone_set, variable "TZ" won't change anything for you. # For older PHP versions (up to 5.2 or 5.3): # - in PHP script: <?php putenv("TZ=UTC"); ?> # - in .htaccess: SetEnv TZ UTC # For newer versions of PHP (function exists since 5.1, but required since 5.4 or so): # - in PHP script: <?php date_default_timezone_set('UTC'); ?> # - in .htaccess: php_value date.timezone 'UTC' Ok, but how and where do I put this php script code? In all my pages, or in only one file? Inside root folder? Edited August 25, 2019 by roguitar
Piotr GRD Posted August 26, 2019 Posted August 26, 2019 It's your decision. Depends where you need it. You can use .htaccess version in root folder of the domain name (public_html) for all PHP scripts or just in .htaccess inside some subfolder for PHP scripts inside that specific subfolder. Or you can use PHP version, which obviously will work only inside the script itself (and override .htaccess setting). Most easy is to use one file (configuration file) included in all the other files. But if your scripts/pages are completely separate and have no common part (like for example included configuration file) then in every single .php file where you need it. Most easy is to put it just in the .htaccess, of course, then you don't have to edit PHP scripts at all, if this is problem for you.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now