Here, you will see the example of setting the date default timezone in PHP
Here, you will see the example of setting the date default timezone in PHP
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.';
}
?>