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

How to Set the PHP Timezone in php.ini

This guide shows you how to tell PHP which timezone to use, so dates and times on your site are correct.

How-To Guides2 min read13 steps4 screenshots

Why does the timezone matter?

PHP is a language that many websites use. When it shows a date or time, it needs to know where in the world you are. Without that, a blog post may show a time that is hours off. The php.ini file is a text file with PHP's settings. The timezone setting lives there.

Steps

Take a backup copy of php.ini before you change it.

  1. Log in to your hosting control panel.
  2. Open the File Manager.
  3. Go to your website folder, often public_html.
  4. Find php.ini. If it does not exist, create a new file with that name.
  5. Right-click the file and choose Edit.
  6. Look for a line that starts with date.timezone. It may have a semicolon at the start. A semicolon means the line is switched off.
  7. Remove the semicolon and set your timezone. If the line is missing, add it:
    Screenshot: Remove the semicolon and set your timezone. If the line is missing, add it:
date.timezone = "Asia/Kolkata"

This sets the timezone to India time. Use the name of your own city or region.

  1. Click Save Changes.
    Screenshot: Click Save Changes .

How to find the right name

PHP uses names like Region/City. Here are a few examples:

  • America/New_York
  • Europe/London
  • Asia/Dubai
  • Australia/Sydney

PHP has a full list in its official manual. Search for "PHP list of supported timezones".

Check that it works

  1. Create a file named time.php in your website folder.
  2. Put this inside it:
<?php echo date_default_timezone_get(); ?>

This prints the timezone PHP is using now.

  1. Open yourdomain.com/time.php in your browser.
  2. Check that the name matches what you set.
    Screenshot: Check that the name matches what you set.
  3. Delete time.php when you are done.
Tip: If you cannot edit php.ini on your plan, look for a PHP settings or PHP selector tool in your control panel. You can also ask Hostvento support.

Quick recap

  • PHP needs a timezone to show the right time.
    Screenshot: PHP needs a timezone to show the right time.
  • Set date.timezone in php.ini.
  • Use the Region/City format.
  • Test with a small file, then delete it.