PHP date_default_timezone_set() Function

Definition

The date_default_timezone_set() function sets the default timezone used by date/time functions.

Syntax

PHP date_default_timezone_set() Function has the following syntax.

date_default_timezone_set(timezone);

Parameter

  • timezone - Required. Timezone to use, like "UTC" or "Europe/Paris".

Return

PHP date_default_timezone_set() Function returns FALSE if the timezone is not valid. TRUE otherwise.

Example

Set the default timezone:


<?php
date_default_timezone_set("Asia/Bangkok");
echo date_default_timezone_get();
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions