Change timezone on PHP

There are some methods that allows you to change the timezone of the PHP (5.1+) scripts (ie, when the date is not shown due to a different timezone of the server).

The first one is by modifying the php.ini file of the web server (if you are allowed to). We just need to add the following line:

date.timezone = "America/Lima"

Other method is using the ini_set() function directly on your script (at the beginning of it), this way:

ini_set('date.timezone', 'America/Lima');

And the third method consist on the use of the function date_default_timezone_set() (also, directly on your script):


The list of the available timezones is here.

Sources: SiteGround, The Electric Toolbox

Leave a Reply

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

Are you human? *

This site uses Akismet to reduce spam. Learn how your comment data is processed.