Share on Google+Share on Google+


This example will tell you about getting date default timezone in PHP.


date_default_timezone_get  function is used for retrieving the default timezone used by all date/time functions in a script. It returns a string. 


string date_default_timezone_get ( void )

This function returns the default timezone in order of preference like:

First reading the timezone set using the date_default_timezone_set() function (if any)

Reading the timezone environment variable (if non empty)

Reading the value of the date.timezone ini option (if set)

Querying the host operating system (if supported and allowed by the OS)

If none of the above succeed, date_default_timezone_get will return a default timezone of UTC.



if (date_default_timezone_get()) {
echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />';

if (ini_get('date.timezone')) {
echo 'date.timezone: ' . ini_get('date.timezone');


The above example will output something similar to:

date_default_timezone_set: India/Kolkata

date.timezone: India/Kolkata


Posted on: August 25, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.