Time zone: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
==Change Server Time Zone== | |||
On cPanel Server, we can change Server Time Zone from WHM. | On cPanel Server, we can change Server Time Zone from WHM. | ||
| Line 10: | Line 12: | ||
It is recommended to reboot the server. | It is recommended to reboot the server. | ||
==MySQL time zone== | |||
By default, this will match server time. If you change the time zone for the server, mysql needs to be restarted before the new time will be seen. If you needed to set the mysql timezone directly for some reason, you can use: | |||
Import timezone tables into mysql (IF NEEDED) | |||
<pre>mysql_tzinfo_to_sql /usr/share/zoneinfo/|mysql -u root mysql</pre> | |||
Set timezone in /etc/my.cnf | |||
<pre> | |||
default_time_zone='Australia/Melbourne' | |||
</pre> | |||
<pre> | |||
service mysql restart | |||
</pre> | |||
==PostgreSQL timezone== | |||
Check Current time: | |||
<pre> | |||
show timezone; | |||
</pre> | |||
Change | |||
<pre> | |||
ALTER DATABASE DBNAME SET timezone to 'America/New_York'; | |||
</pre> | |||
Exit, re-login, and verify. | |||
==Crontab/shell timezone== | |||
Login as user via SSH: | |||
<pre> | |||
echo 'export TZ="/usr/share/zoneinfo/America/Detroit"' >> ~/.bashrc | |||
source ~/.bashrc | |||
</pre> | |||
Latest revision as of 16:10, 20 June 2024
Change Server Time Zone
On cPanel Server, we can change Server Time Zone from WHM.
Step 1: Log into WHM
Step 2: Navigate to Server Time.
Step 3: Select the new TimeZone from the drodown.
Step 4: Click Save.
It is recommended to reboot the server.
MySQL time zone
By default, this will match server time. If you change the time zone for the server, mysql needs to be restarted before the new time will be seen. If you needed to set the mysql timezone directly for some reason, you can use:
Import timezone tables into mysql (IF NEEDED)
mysql_tzinfo_to_sql /usr/share/zoneinfo/|mysql -u root mysql
Set timezone in /etc/my.cnf
default_time_zone='Australia/Melbourne'
service mysql restart
PostgreSQL timezone
Check Current time:
show timezone;
Change
ALTER DATABASE DBNAME SET timezone to 'America/New_York';
Exit, re-login, and verify.
Crontab/shell timezone
Login as user via SSH:
echo 'export TZ="/usr/share/zoneinfo/America/Detroit"' >> ~/.bashrc source ~/.bashrc