How to set India Time Zone to PHP

If your web application store the current date and time to your database when user fill the data or submit any form, you have to set the timezone to save date and time according to your timezone.

You can set the default timezone in following two ways in php.

1) Change to the php.ini file by the changing the default timezone
If you are not aware about to update the php.ini file, please follow the following instructions.

  • Open your php.ini file with the File Manager in cPanel
  • Locate and then open your php.ini file for editing.
  • Add the following line of code to top of your php.ini file

Once you update the php.ini file, please check your phpinfo.php page to verify the change took place. It should looks like below image

You can find the list of Supported Timezones, from the following link:
https://www.php.net/manual/en/timezones.asia.php

2) Add below line to your PHP file (It’s recommended to add it to your main PHP configuration file):
date_default_timezone_set(‘Asia/Kolkata’)

Leave a Reply

Your email address will not be published. Required fields are marked *