Setting the Timezone for PHP in the php.ini file

I tried all the other possible solutions posted, but none of them helped. This is what helped me save my timezone settings:

1) Go to your phpinfo() page and search for Loaded Configuration File and open the php.ini file mentioned under that section.

2) Change the default timezone settings by adding your new timezone by modifying this line: date.timezone=Asia/Kolkata.

3) Save the php.ini file and stop the Apache server.

4) Restart the Apache server. The timezone settings should now be modified.


You can change it in the code without touching the ini file, at the beginning of your code add:

date_default_timezone_set('Asia/Calcutta')

Tags:

Datetime

Php