Home Tutorial Php Phpdate date_default_timezone_get

 
 

Share on Google+Share on Google+
date_default_timezone_get
Posted on: August 25, 2009 at 12:00 AM
Advertisement
This example will tell you about getting date default timezone in PHP.

 date_default_timezone_get

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. 

Description

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.

Examples

<?php
date_default_timezone_set('India/Kolkata');

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

Advertisement

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
 

 

 

DMCA.com