If the correct time is not displaying in your PHP scripts, you will need to make some changes on your hosting server. This can be easily done by adding a line of code to your php.ini file.
So let’s see how to set the Timezone for PHP:
Step 1: Open your php.ini file with the File Manager in cPanel
Step 2: Add the below-mentioned line of code to top of your php.ini file
date.timezone = "US/Central"
Step 3: Replace “US/Central” with the timezone from here that corresponds to the time you want to display.
Step 4: Once you have entered the timezone you want to set, click the Save Changes button to save the file.
Step 5: Now, you can check your phpinfo.php page to verify the change took place.