Home Tutorial Php Phpdate date_default_timezone_set

 
 

Share on Google+Share on Google+
date_default_timezone_set
Posted on: August 25, 2009 at 12:00 AM
Advertisement
Here, you will see the example of setting the date default timezone in PHP

 

date_default_timezone_set

date_default_timezone_set function sets the default timezone used by all date/time functions in a script. This function returns False if the timezone_identifier isn't valid, otherwise True.

Description

bool date_default_timezone_set ( string $timezone_identifier )

It is notable that default timezone can also be set by using INI setting date.timezone. 

Parameters

timezone_identifier

The timezone identifier refers to the Coordinated Universal Time (UTC) or Greenwich Mean Time (GMT) or region based time like India/Kolkata. 

Examples

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

$script_tz = date_default_timezone_get();

if (strcmp($script_tz, ini_get('date.timezone'))){
echo 'Script timezone differs from ini-set timezone.';
} else {
echo 'Script timezone and ini-set timezone match.';
}
?>

Advertisement

Related Tags for date_default_timezone_set:


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