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
1 | date.timezone=Asia/Kolkata |
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’)
1 2 | date_default_timezone_set("Asia/Calcutta"); echo date('d-m-Y H:i:s'); |