Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Change the PHP Time Zone on Your Hosting

This guide shows how to set the right time zone for your PHP website, so dates and times show correctly.

Reseller Hosting2 min read11 steps

Why does the time zone matter?

PHP is a language many websites use. It has its own clock setting called a time zone. If the zone is wrong, your posts, orders and emails may show the wrong time. A time zone is a region of the world that shares the same clock time, like "Asia/Kolkata" or "America/New_York".

Method 1: Select PHP Version in cPanel

cPanel is the control panel on most shared and reseller hosting. Menu names can differ a little between versions.

  1. Log in to cPanel.
  2. In the Software section, click Select PHP Version.
  3. Click the Options tab. On some servers, the same page is called MultiPHP INI Editor in the Software section.
  4. Look for the date.timezone setting. Type your time zone in the box, for example Asia/Kolkata.
  5. Click Apply or Save.

Method 2: Use a php.ini file

A php.ini file holds PHP settings for your folder.

  1. Open File Manager in cPanel and go to public_html.
  2. If a php.ini file does not exist, click + File and create it. Otherwise, right-click it and choose Edit.
  3. Add this line:
date.timezone = "Asia/Kolkata"

This tells PHP to use that time zone. Replace it with your own zone.

  1. Save the file.

Method 3: Set it in your code

You can also add this line at the top of a PHP file:

<?php date_default_timezone_set('Asia/Kolkata'); ?>

This sets the zone for that script only.

Check your change

  1. Create a file called time.php with this inside:
<?php echo date('Y-m-d H:i:s T'); ?>
  1. Open it in a browser and check the time. Delete the file afterwards.
Tip: Look up the exact zone name on a "list of PHP time zones" page. Spell it exactly, with capital letters. Some apps, such as WordPress, also have their own time zone setting in their admin area.

Quick recap

  • The PHP time zone controls the dates and times your site shows.
  • Set date.timezone in Select PHP Version or in php.ini.
  • Or use date_default_timezone_set in code.
  • Test with a small script.