Home >Backend Development >PHP Tutorial >PHP date time difference 8 hours solution_PHP tutorial

PHP date time difference 8 hours solution_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:54:261040browse

Add time initialization statement in the program: "date_default_timezone_set("asia/shanghai");

Definition and usage

the date_default_timezone_set() function sets the default timezone used by all date/time functions.
The date_default_timezone_set() function is used to set the default time zone for all date and time functions in a script.

syntax
Grammar

date_default_timezone_set(timezone)

parameter
parameter
参数
description
描述
timezone required. the timezone identifier, like "utc" or "europe/paris". list of valid timezones: http://www.php教程.net/manual/en/timezones.php
必要参数,时区确认器,如“utc”或“europe/paris”。下面列出了有效的时区:http://www.php.net/manual/en/timezones.php
Parameters
description Description
timezone required. the timezone identifier, like "utc" or "europe/paris". list of valid timezones: http://www.php tutorial.net/manual/en/timezones.php
Required parameter, time zone validator, such as "utc" or "europe/paris". Valid time zones are listed below: http://www.php.net/manual/en/timezones.php


tips and notes

Note
note:

this function always returns true (even if the timezone parameter isn't valid).
Note: This function always returns true (even if the time zone parameter is invalid).


example

Case

<?phpecho(date_default_timezone_set("europe/paris"));?>


the output of the code above will be: The above code will output the following results:

http://www.bkjia.com/PHPjc/632328.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632328.htmlTechArticle
Add time initialization statement in the program: date_default_timezone_set(asia/shanghai); Definition and usage the date_default_timezone_set() function sets the default timezone used by all d...
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