Home >Backend Development >PHP Problem >How to use php date_default_timezone_set function

How to use php date_default_timezone_set function

青灯夜游
青灯夜游Original
2019-05-26 13:40:243542browse

The date_default_timezone_set() function is a built-in function in PHP that is used to set the default time zone used by all date/time functions in the script. This function returns False if the time zone is invalid, True otherwise.

How to use php date_default_timezone_set function

How to use php date_default_timezone_set() function?

php date_default_timezone_set() function sets the default time zone used by all date/time functions in the script.

Syntax:

date_default_timezone_set(timezone);

Parameters: This function accepts a single required parameter

● timezone: required. Set the time zone identifier, specifying the time zone to use, such as "UTC" or "Europe/Paris".

Return value: If timezone_identifier is invalid, this function returns False, otherwise it returns True.

Let’s take a look at how to use the php date_default_timezone_set() function through an example.

Example

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

Output:

Asia/Shanghai

The above is the detailed content of How to use php date_default_timezone_set function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn