PHP | date_default_timezone_get() Function Last Updated : 09 Nov, 2021 Comments Improve Suggest changes Like Article Like Report The date_default_timezone_get() function is an inbuilt function in PHP which is used to gets the default timezone used by all date/time functions in a script. Syntax: string date_default_timezone_get( void ) Parameter: This function does not accept any parameter.Return Value: This function returns a string. Note: This function returns the default timezone by: Reading the timezone using the date_default_timezone_set() function.Before PHP 5.4.0, Reading the TZ environment variable.Reading the value of the date.timezone ini optionBefore PHP 5.4.0, Querying the host operating system (if supported and allowed by the OS). This uses an algorithm that has to guess the timezone. If any statement of the above is not true then date_default_timezone_get() will return a default timezone of UTC. Below programs illustrate the date_default_timezone_get() function in PHP: Program 1: PHP <?php // Set the default timezone date_default_timezone_set('Asia/Kolkata'); // Create timezone object $timezone_object = date_default_timezone_get(); // If timezone object is true if ($timezone_object) { echo 'date_default_timezone_set: ' . date_default_timezone_get(); } ?> Output: date_default_timezone_set: Asia/Kolkata Program 2: PHP <?php // Set the default timezone date_default_timezone_set('Asia/Kolkata'); echo date_default_timezone_get() . ' => ' . date('e') . ' => ' . date('T'); ?> Output: Asia/Kolkata => Asia/Kolkata => IST Related Articles: PHP | date_sun_info() FunctionPHP | date_parse() FunctionPHP | date_sunset() Function Reference: http://php.net/manual/en/function.date-default-timezone-get.php Comment More infoAdvertise with us Next Article PHP | date_default_timezone_get() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP PHP-date-time PHP-function +1 More Practice Tags : Misc Similar Reads PHP | date_default_timezone_set() Function The date_default_timezone_set() function is an inbuilt function in PHP which is used to set the default timezone used by all date/time functions in a script. This function returns False if the timezone is not valid, or True otherwise. Syntax: bool date_default_timezone_set( $timezone_identifier ) Pa 2 min read PHP | date_timezone_get() Function The date_timezone_get() function is an inbuilt function in PHP which is used to return time zone relative to given DateTime. This function returns a DateTimeZone object on success or False on failure. Syntax: Procedural style: date_timezone_get( $object ) Object oriented style: DateTime::getTimezone 1 min read PHP | date_timezone_set() Function The date_timezone_set() function is an inbuilt function in PHP which is used to sets the time zone for the DateTime object. This function returns the DateTime object or False on failure. Syntax: Procedural style: date_timezone_set( $object, $timezone ) Object oriented style: DateTime::setTimezone( $ 2 min read PHP | date_timestamp_get() Function The date_timestamp_get() function is an inbuilt function in PHP which is used to gets the Unix timestamp. This function returns the Unix timestamp representing the date. Syntax: Procedural style: int date_timestamp_get( $object ) Object oriented style: int DateTime::getTimestamp( void ) int DateTime 1 min read PHP | timezone_name_get() Function The timezone_name_get() function is an inbuilt function in PHP which is used to return the name of the timezone. The date time object is sent as a parameter to the timezone_name_get() function and it returns the name of the timezone on success or False on failure. Syntax: string timezone_name_get( $ 2 min read PHP | timezone_name_from_abbr() Function The timezone_name_from_abbr() function is an inbuilt function in PHP which is used to return the timezone name from abbreviation. The abbreviation is sent as a parameter to the timezone_name_from_abbr() function and it returns the name of the timezone on success or False on failure. Syntax: string t 2 min read PHP | timezone_open() Function The timezone_open() function is an inbuilt function in PHP which is used to create a new DateTimeZone object. The timezone_open() function accepts the timezone as a parameter and returns the DateTimeZone object on success or False on failure. Syntax: timezone_open( $timezone ) Parameters: This funct 2 min read PHP | DateTimeImmutable::setTimezone() Function The DateTimeImmutable::setTimezone() function is an inbuilt function in PHP which is used to set the time zone for the created DateTimeImmutable object. This function returns the DateTimeImmutable object or False on failure. Syntax: DateTimeImmutable::setTimezone ( TimeZone ) Parameters: This functi 1 min read PHP | timezone_abbreviations_list() Function The timezone_abbreviations_list() function is an inbuilt function in PHP which is used to return an associative array containing dst, offset, and the timezone name. No parameters are required to send to the timezone_abbreviations_list() function and it returns an associative array on success or Fals 3 min read PHP | date_date_set() Function The date_date_set() function is an inbuilt function in PHP which is used to set a new Date. This function has four parameters $object, $year, $month and $day and returns DateTime object on success or false on failure. The date_date_set() function is an alias of DateTime::setDate() function. Syntax: 2 min read Like