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

Warnings at at Utilities > Automation Status can also indicate a problem in your system cron configuration. For more information, see Cron Frequency Warnings.

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:

  1. Use the steps below to check the cron engine timezone using SSH or using a cron job.
  2. 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:

  1. 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:
    php -ini | grep "date.timezone"
    
    You will receive output that resembles the following example:
    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.
    
  2. Compare the output to the date.timezone value in your WHMCS installation’s PHP configuration at Utilities > System > PHP Info.
    The date.timezone directive in the PHP Info list of directives.

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.

If you use cPanel, you can create cron jobs at Advanced » Cron Jobs.

To do this:

  1. 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.
  2. Wait for at least one minute while the cron job runs.
  3. Check the output in the phpoutput.txt file for a date.timezone value:
    <tr><td class="e">date.timezone</td><td class="v">UTC</td><td class="v">UTC</td></tr>
    
    In the above example, the cron engine’s timezone is UTC.
After you retrieve this value, we recommend removing the custom cron job.

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.
For a full list of the available timezone localities to use, see the PHP list of timezones.

Update the Server Clock

Use your preferred method to update the server clock to the correct timezone.

  • 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
For help to update your PHP configuration, contact your hosting provider or system administrator.

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: May 29, 2024