System Timezone Issues
Problem
You experience timezone-related issues in WHMCS or while running WHMCS automation. For example:
- The timezone displays incorrectly on pages in the Client Area or Admin Area.
- Timestamps are incorrect in imported support ticket email replies.
- You or your customers experience problems while using two-factor authentication.
- You see a warning message at Utilities > Automation Status stating that the system cron has not run within the past two hours.
- The system cron is not running at the time you selected at at Configuration () > System Settings > Automation Settings.
Cause
The server clock and the timezone setting in your PHP configuration determine the timezone under which your WHMCS installation runs. Timezone-related issues may indicate timezone misconfiguration or a timezone mismatch between the webserver’s PHP configuration and the cron engine’s PHP configuration.
You must ensure that the timezone WHMCS’s PHP configuration uses is the same as the PHP configuration that the command line uses, and, by extension, the cron job is using.
Troubleshooting
First, check the server clock timezone. If the server clock timezone is correct, check your PHP configurations.
To check whether your PHP configuration timezones match:
- Use the steps below to check the cron engine timezone using SSH or using a cron job.
- Check the webserver’s timezone in the PHP configuration information at Utilities > System > PHP Info.
Check Using SSH
To check the cron engine timezone using SSH:
- Use your preferred command line tool to log in to the server as the user under which the cron job runs and run the following command:
You will receive output that resembles the following example:php -ini | grep "date.timezone"
date.timezone => UTC => UTC
- We recommend using a user who is **not** the `root` user when troubleshooting issues on the command line. Properly-configured servers typically do not use the `root` user to run the webserver or cron processes. - If you use cPanel and have the required permissions, you can also do this at **Home >> Advanced >> <a href="https://docs.cpanel.net/cpanel/advanced/terminal-in-cpanel/" target="_blank">Terminal</a>** in the cPanel account that hosts your WHMCS installation.
- Compare the output to the
date.timezone
value in your WHMCS installation’s PHP configuration at Utilities > System > PHP Info.
Check Using a Cron Job
If you do not have command line access but can create a cron job, you can check the cron engine timezone by creating a custom cron command.
To do this:
- Use your preferred method to create a cron job that uses the following command, where
/home/example/public_html/whmcs/
is the path to your WHMCS installation:php -i | grep "date.timezone" > /home/example/public_html/whmcs/crons/phpoutput.txt
- This command will create a file that contains the cron engine’s timezone and save it in the
crons
directory when the cron job runs. - Configure the cron job to run once per minute of every hour, every day, every month, and every weekday.
- This command will create a file that contains the cron engine’s timezone and save it in the
- Wait for at least one minute while the cron job runs.
- Check the output in the
phpoutput.txt
file for adate.timezone
value:
In the above example, the cron engine’s timezone is<tr><td class="e">date.timezone</td><td class="v">UTC</td><td class="v">UTC</td></tr>
UTC
.
Solution
Perform the necessary steps to ensure that all timezones are correctly-configured.
- If the server clock is incorrect, reconfigure it to use the correct value.
- If the PHP configuration timezones differ, either update the timezones to ensure that they match or set the timezone in your cron command directly.
Update the Server Clock
Use your preferred method to update the server clock to the correct timezone.
For example, to use uGoogle’s NTP server, run the following command on your server:
ntpdate time.google.com
- Exercise caution when changing the server clock on a server that hosts clients.
- Changing the server clock requires
root
access to the server. For help, contact your hosting provider or system administrator.
Edit the PHP Configuration
Some hosting providers allow you to change the PHP configuration on an individual directory by creating a php.ini
file within the WHMCS directory. To do this, you could add the following line:
date.timezone=Europe/London
Set the Timezone in the Cron Command
Update the system cron command to explicitly specify the webserver’s timezone when it runs. For example:
php -d date.timezone='Example-Timezone' /path/to/crons/cron.php
Last modified: October 25, 2024