date_default_timezone_get()

date_default_timezone_get() — Gets the default timezone used by all date/time functions in a script.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.1.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

In order of preference, this function returns the default timezone by: Reading the timezone set using the date_default_timezone_set() function (if any) Reading the value of the date.timezone ini option (if set)

Signature

date_default_timezone_get(): string

Parameters

This function takes no parameters.

Return value

Returns a string.

Example

A runnable snippet:

date_default_timezone_set('Europe/London'); if (date_default_timezone_get()) { echo 'date_default_timezone_set: ' . date_default_timezone_get() . "\n"; } if (ini_get('date.timezone')) { echo 'date.timezone: ' . ini_get('date.timezone'); }

Output:

date_default_timezone_set: Europe/London date.timezone: Europe/London

See also

date_default_timezone_set()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page date_default_timezone_get() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.