Jump to content

[Solved] Changing server time zone


roguitar

Recommended Posts

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/ .

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'
Link to comment
Share on other sites

 

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 by roguitar
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...