date_default_timezone_set in PHP

Syntax of date_default_timezone_set

string date_default_timezone_get()

Returns the current default time zone, set previously by the date_default_timezone_set() function or via the date.timezone option in the php.ini file. Returns “UTC” if neither is set.

Example of date_default_timezone_set


$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.';

Leave a Comment