Set Timezone In PHP By Editing php.ini File

Do you want to set timezone in PHP? PHP runs on a server and each server has set the timezone in the ini file. Your websites server side date and time works according to this default timezone. In this article, we discuss how one can set timezone in PHP by using their php.ini file.

Why Need To Change Timezone

There are several reasons, you might need to change default timezone. Maybe you are building a website and you want to keep date and time of your timezone during the development stage, you are getting confused with the server date time and actual date time of your timezone, etc.

If your website is working globally and you need to deal with different timezones then please read our article on How To Handle Timezones In PHP

Edit php.ini To Set Default Timezone

Open your php.ini file in the editor and find the word timezone. You will find the statement like below.

date.timezone = Asia/Kolkata

Set Timezone In PHP

Here, you can set the timezone you wish to apply for your website. You simply get list of timezones from this link List of Supported Timezones

For instance, I need to set my timezone to ‘Chicago’. The timezone string for this timezone is ‘America/Chicago’ so I will add below code in my php.ini file.

date.timezone = America/Chicago

At this stage, you need to restart your server to take effect.

That’s all! I hope you understand how to set timezone in PHP. For any questions or suggestions, please leave a comment below.

If you liked this article, then please subscribe to our YouTube Channel for video tutorials.

1 thought on “Set Timezone In PHP By Editing php.ini File

Leave a Reply

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