How to change the date.timezone value in PHP?

If your PHP scripts do not show the correct time, the reason is that most probably your hosting server is in a different timezone. This can be easily done by changing a setting using PHP called date.timezone.

Depending on your location you can set a specific date.timezone value in PHP using the option below which should be added to your local php.ini file :-

date.timezone = “Pacific/Auckland

The example given above assumes you’d like to set the timezone for your PHP scripts to Pacific/Auckland. The full list of supported time zones is available here and you should simply replace Pacific/Auckland with the desired timezone.

Example Script :-

ini_set(‘date.timezone’, ‘Pacific/Auckland’);
echo $today = date(“D M j G:i:s T Y”);

Output :-

Before :-

After :-

Current time after changing the value of default time zone


I like to hear from you about this !!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

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