Your order emails say a customer bought something at 3:12 AM. Your cron backup that's "set for midnight" actually runs at 5:30 in the morning. WordPress shows one time, phpMyAdmin shows another, and date over SSH shows a third. The server clock isn't broken. It's almost always a timezone mismatch somewhere in the stack, and since a typical site has four or five separate places where timezone gets set, one of them is usually still on UTC.

Here's how to find which layer is wrong and get the whole stack onto the same timezone (for most of our customers that's Asia/Kolkata, which is IST, UTC+5:30).

Symptom: What a Timezone Mismatch Looks Like

  • Timestamps that are off by exactly 5 hours 30 minutes. That's the giveaway: UTC vs IST.
  • Cron jobs firing at the "wrong" hour, even though the schedule looks right.
  • WooCommerce orders, contact form entries or log lines dated the previous day.
  • WordPress Site Health or Settings → General showing "Universal time is…" and "Local time is…" values that don't match what you expect.
  • PHP warnings like date(): It is not safe to rely on the system's timezone settings on older code.

If the time is off by some random amount (say 7 minutes, or 43 seconds), that's a different problem: actual clock drift. Fix that with NTP/chrony first, then come back here.

Cause: Five Layers, Five Separate Settings

Each layer has its own idea of "now", and they don't automatically inherit from each other:

LayerWhere it's setHow to check
Operating system/etc/localtime (via timedatectl)timedatectl
PHPdate.timezone in php.iniphp -i | grep date.timezone
MySQL / MariaDBdefault-time-zone in my.cnf, or per-sessionSELECT @@global.time_zone, NOW();
WordPressSettings → General → Timezone (timezone_string option)wp option get timezone_string
CronFollows the OS timezone (or CRON_TZ)grep CRON_TZ /etc/crontab and your crontab

On a fresh VPS the OS is almost always UTC. On shared cPanel hosting you can't change the OS timezone, but you can control PHP, WordPress and your own database sessions. Usually one layer was set to IST and nobody touched the others.

Fix: Work Through the Stack Top to Bottom

1. Operating system (VPS only)

Check what you've got:

timedatectl

Look at the Time zone: line. If it says Etc/UTC (UTC, +0000) and you want IST:

sudo timedatectl set-timezone Asia/Kolkata
timedatectl

On older systems without systemd:

sudo ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

Then restart the services that cache timezone at startup. Cron and syslog are the ones people forget:

# Ubuntu / Debian
sudo systemctl restart cron rsyslog

# AlmaLinux / Rocky
sudo systemctl restart crond rsyslog
Should a server even be on local time? Plenty of engineers keep servers on UTC and convert at the application layer, especially when users or servers are spread across regions. That's a perfectly good choice. Whichever you pick, be consistent: the real problem is mixing them.

2. PHP

PHP ignores the OS timezone if date.timezone is set in php.ini, and it falls back to UTC if it isn't set at all. Check what the web PHP is using, not just the CLI, because they can load different ini files:

<?php echo date_default_timezone_get(), ' — ', date('Y-m-d H:i:s');

Save that as tz.php in your web root, load it in a browser, then delete it.

On cPanel: go to Software → MultiPHP INI Editor, pick your domain, switch to Editor Mode and add:

date.timezone = "Asia/Kolkata"

On a VPS with nginx-primary-script-unknown-file-not-found-on-a-vps" class="auto-link">PHP-FPM: edit the ini for your PHP version and reload FPM:

# Ubuntu example for PHP 8.3
sudo nano /etc/php/8.3/fpm/php.ini
#   date.timezone = Asia/Kolkata
sudo systemctl reload php8.3-fpm

# also set it for CLI scripts and cron
sudo nano /etc/php/8.3/cli/php.ini

Use the full region name. IST isn't a valid PHP timezone identifier (and it's ambiguous anyway: Irish and Israel Standard Time use the same letters).

3. MySQL / MariaDB

Run this in phpMyAdmin's SQL tab or the mysql shell:

SELECT @@global.time_zone, @@session.time_zone, NOW(), UTC_TIMESTAMP();

SYSTEM means it follows the OS. On a VPS you can pin it in /etc/mysql/my.cnf (or /etc/my.cnf on RHEL-family systems):

[mysqld]
default-time-zone = '+05:30'

then sudo systemctl restart mysql (or mariadb). Named zones like 'Asia/Kolkata' only work once you've loaded the timezone tables:

mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql -u root mysql

One thing that trips people up: TIMESTAMP columns are stored in UTC and converted on read using the session timezone, while DATETIME columns are stored exactly as written. If you change the server timezone, existing TIMESTAMP values will display differently and DATETIME values won't. That's expected, so don't go "fixing" old rows by hand.

On shared hosting, where you can't touch my.cnf, set it per connection in your app:

SET time_zone = '+05:30';

4. WordPress

WordPress deliberately runs PHP in UTC internally and applies its own timezone setting on top. So don't call date_default_timezone_set() in a theme or plugin. It breaks scheduling and WooCommerce in subtle ways.

Go to Settings → General → Timezone and pick a city (Kolkata), not a manual offset like UTC+5:30. City-based zones handle daylight saving for regions that observe it, and plugins read timezone_string more reliably than gmt_offset. With WP-CLI:

wp option update timezone_string 'Asia/Kolkata'
wp option get timezone_string

If timestamps in your custom code still look off, use WordPress's own helpers (wp_date(), current_time('mysql')) instead of raw date().

5. Cron jobs

Cron uses the system timezone as it was when the cron daemon started. That's why people change the timezone and their jobs still run at the old hour. Restart cron (step 1) and it'll pick up the change.

On shared cPanel hosting the server timezone is set by the host, so work out your schedule from that. Check it with a quick cron that logs the time:

* * * * * date >> $HOME/cron-time.log 2>&1

Let it run a couple of minutes, read the log, then remove the job. If the server is on UTC and you want something at 2:00 AM IST, schedule it for 20:30 the previous day: 30 20 * * *.

On a VPS, some cron implementations (cronie on AlmaLinux/Rocky) also support a per-crontab override:

CRON_TZ=Asia/Kolkata
0 2 * * * /home/user/backup.sh

Debian/Ubuntu's default cron doesn't reliably honour CRON_TZ, so test it with the logging trick before you rely on it.

Verify Everything Lines Up

Run these back to back. All of them should agree to within a second or two:

date
php -r 'echo date("Y-m-d H:i:s T"), PHP_EOL;'
mysql -e 'SELECT NOW();'
wp eval 'echo current_time("mysql"), PHP_EOL;'

Then check one web request (the tz.php test from step 2) because the CLI and FPM can disagree.

Prevention

  • Make timezone part of your VPS first-hour checklist. Set it once, right after provisioning, before anything writes timestamps.
  • Pick one strategy and write it down. Either "everything IST" or "servers UTC, convert in the app". Not both.
  • Set PHP's timezone explicitly for both FPM and CLI so a PHP version upgrade (which brings a fresh php.ini) doesn't silently reset you to UTC.
  • Keep NTP running (timedatectl should show System clock synchronized: yes). Timezone and accuracy are separate problems, and you want both right.
  • Store event times in UTC where you can in custom apps, and convert for display. That stays correct even if you change servers or regions later.

Frequently Asked Questions

Why is my time off by exactly 5 hours 30 minutes?

That's the gap between UTC and IST. One layer (usually the OS, PHP or MySQL) is still on UTC while another is on Asia/Kolkata. Use the verification commands above to find which one.

Can I change the server timezone on shared cPanel hosting?

No, the OS timezone is shared by every account on the server. You can still set PHP's date.timezone in the MultiPHP INI Editor, your WordPress timezone, and the MySQL timezone per session, and that covers what your site actually displays. For cron, work out the schedule from the server's timezone.

I changed the timezone but cron still runs at the old time. Why?

The cron daemon reads the timezone when it starts. Restart it with systemctl restart cron (Ubuntu/Debian) or systemctl restart crond (AlmaLinux/Rocky) and the new timezone takes effect.

Will changing the MySQL timezone corrupt my existing data?

No. TIMESTAMP values are stored in UTC and just display in the new timezone; DATETIME values stay exactly as they were written. Nothing is rewritten on disk. Do test reports and anything that compares dates, though, since displayed values may shift.

Should I use "UTC+5:30" or "Kolkata" in WordPress?

Use the city, Kolkata. It sets timezone_string, which plugins like WooCommerce and schedulers handle more reliably than a raw offset, and it copes properly with daylight saving if you ever switch to a region that uses it.