Share on Google+Share on Google+

date_default_timezone_set

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.';
}
?>

Advertisements

Advertisement

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.