Search The Hostwinds Guides Knowledge Base

How To Set or Change PHP Time-zone

Share This Article

This guide is intended to provide guidance on how to set-up or change the PHP timezone for Linux based services here at Hostwinds; setting and/or editing through cPanel, WHM or commands within Linux.

How To Edit PHP Time-zone With Hostwinds Shared and/or Business Hosting Services

Step 1:  Log into your cPanel account (How to log into cPanel)

Step 2:  Select File Manager

showing cPanels File Manager Icon

Step 3: Select Settings and make sure Show Hidden Files is checked, then click save.

Step 4: Navigate to the folder public_html, and you should see a file called .htaccess within this directory. If you are not able to see files that start with a dot and this is hidden, please make sure you have enabled showing hidden or dot files in File Manager.

cpanel public_html directory location image

Step 5:  Right hand click on the .htaccess file and select edit. If this file does not exist, you will want to create a new file named .htaccess.

public_html .htaccess edit location image

Step 6:  Search if there is already a timezone within the file; it should look like php_value date.timezone ‘Region/Timezone or SetEnv TZ ‘Region/Timezone’

Step 7:  If there is or is not, edit or add the following line within .htaccess with the time-zone you wish:

php_value date.timezone 'Region/Timezone'

(Please review here for available time-zones for PHP)

save changes button

Step 8:  When complete, your .htaccess should have the code look similar to the below image.  Save Changes ( top right) to the file when done

public_html .htaccess file image

As our shared and business services are shared, editing .htaccess will provide a quick resolution when needing to update your website’s timezone if this needs to be different than America/Los_Angeles.

How To Edit On Hostwinds VPS with WHM/cPanel Installed

Step 1: Log into your WHM (“How to get started with your new WHM/cPanel server“)

Step 2:  Under Server Configuration, select Server Time

WHM server time location image

Step 3: Select the drop-down icon and select the time-zone you wish.  Click the Change Time-Zone button when done.

WHM server time dropdown image

Step 4:  If your server’s current time for whatever reason is not synced, select the Sync Time with Time Server button.  This will ensure your new time is synced with your server moving forward.

WHM graceful reboot proceed button image

Step 5:  Within WHM’s search bar, search for reboot and select Graceful Server Reboot from the available options that appear.  Click “Proceed > () when ready.

WHM graceful reboot search location image

If you would like to edit the individual cPanel(s) PHP timezone, please see the above steps under How to edit on Hostwinds Shared and/or Business Hosting Services.  The same steps will change the PHP timezone for that specific cPanel account.

How To Edit PHP Time-zone Without WHM or cPanel

Directions should apply for any of the following operating systems: CentOS, Ubuntu, Fedora, Windows, and Debian

If SSHing from a Windows computer, please make sure you have a SSH tool installed like PuTTY

Step 1:  See what the current time-zone is by typing the date  command or ls  command

Output:

SSH command window for timezone image

Step 2:  Type the following commands to change the current time within SSH

Administrator or root access is required.  The syntax is as follows to set timezone:

timedatectl set-timezone time_zone

In this example, set timezone to America/Denver

timedatectl set-timezone America/Denver

Your time-zone will now be changed on your server

How Do I Check My Current Time-zone and If It Was Changed?

It is possible to check your current timezone if you do not have access to WHM > Server Time.  The following steps will demonstrate how to get access to your current domains PHP time-zone

Step 1:  Navigate to your cPanel and the Document Root folder (public_html for most cases)

Step 2: Create a file within your root directory called phpinfo.php

public_html/phpinfo.php location image

Step 3:  Once the file is created, select it and right click to edit

phpinfo.php edit dropdown image

Step 4:  Within the blank php file, insert the following code:

<? php phpinfo(); ?>

save changes button

** Save Changes ( top right) to the file when done **

Step 5: Now that the phpinfo.php has been created, navigate to your domain.com/phpinfo.php.  A page similar to this should display.

phpinfo.php screenshot

Step 6:  Find the category Date, Default Timezone and date.timezone (under local) should show your new time.

phpinfo.php timezone location

If we can help you in any way, please submit a ticket, give us a phone call or join us in a Live Chat anytime. We are available 24/7/365 and we are dedicated to our client’s success; every client truly matters to us.