Home Tutorial Php Phpdate date_default_timezone_get


Share on Google+Share on Google+
Posted on: August 25, 2009 at 12:00 AM
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


Related Tags for date_default_timezone_get:

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.

Posted on: August 25, 2009

Recommend the tutorial

Advertisements Advertisements