Jump to content


Photo

[Solved] Changing server time zone

server time zone

  • Please log in to reply
7 replies to this topic

#1 roguitar

roguitar

    Rank II Member

  • Members
  • PipPip
  • 77 posts

Posted 25 August 2019 - 01:59 PM

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?



#2 BlueyEmperor

BlueyEmperor

    Rank II Member

  • Members
  • PipPip
  • 64 posts
  • Gender:Male
  • Interests:Website Design • Video Graphics

Posted 25 August 2019 - 02:04 PM

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.

#3 sohamb03

sohamb03

    Rank VIII Member

  • Members
  • PipPipPipPipPipPipPipPip
  • 713 posts
  • Gender:Male
  • Location:India
  • Interests:Web Designing

Posted 25 August 2019 - 02:17 PM

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.interser...taccess-cpanel/ .

Sayan Bhattacharyya


#4 roguitar

roguitar

    Rank II Member

  • Members
  • PipPip
  • 77 posts

Posted 25 August 2019 - 06:15 PM

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.interser...taccess-cpanel/ .

Well, I've set it to:

 

 

SetEnv TZ America/Sao_Paulo

 

And nothing happened.



#5 sohamb03

sohamb03

    Rank VIII Member

  • Members
  • PipPipPipPipPipPipPipPip
  • 713 posts
  • Gender:Male
  • Location:India
  • Interests:Web Designing

Posted 25 August 2019 - 06:22 PM

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.

Sayan Bhattacharyya


#6 Piotr GRD

Piotr GRD

    Rank IV Member

  • Contributors
  • 228 posts
  • Location:Stettin, Poland (Szczecin, Polska)

Posted 25 August 2019 - 07:07 PM

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'


#7 roguitar

roguitar

    Rank II Member

  • Members
  • PipPip
  • 77 posts

Posted 25 August 2019 - 10:09 PM

 

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, 25 August 2019 - 11:21 PM.


#8 Piotr GRD

Piotr GRD

    Rank IV Member

  • Contributors
  • 228 posts
  • Location:Stettin, Poland (Szczecin, Polska)

Posted 26 August 2019 - 04:23 AM

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.







Also tagged with one or more of these keywords: server, time zone

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users