PHP.nl

date_default_timezone_get

date_default_timezone_get

Gets the default timezone used by all date/time functions in a script

string **date_default_timezone_get**

In order of preference, this function returns the default timezone by:

  • Reading the timezone set using the function (if any) date_default_timezone_set

  • Reading the value of the ini option (if set) date.timezone

    If none of the above succeed, will return a default timezone of . date_default_timezone_get``UTC

    Returns a . string

    Voorbeeld: Getting the default timezone

<?php
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');
}
date_default_timezone_set: Europe/London
date.timezone: Europe/London

Voorbeeld: Getting the abbreviation of a timezone

<?php
date_default_timezone_set('America/Los_Angeles');
echo date_default_timezone_get() . ' => ' . date('e') . ' => ' . date('T');
America/Los_Angeles => America/Los_Angeles => PST

date_default_timezone_set