Home > php教程 > php手册 > php 日期时差8小时间解决方法

php 日期时差8小时间解决方法

WBOY
Release: 2016-06-13 09:55:04
Original
1266 people have browsed it

程序中添加时间的初始化语句:“date_default_timezone_set("asia/shanghai");

定义和用法

the date_default_timezone_set() function sets the default timezone used by all date/time functions.
date_default_timezone_set()函数的作用是:设定用于一个脚本中所有日期时间函数的默认时区。

syntax
语法

date_default_timezone_set(timezone)
Copy after login

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

tips教程 and notes
注意点

note: this function always returns true (even if the timezone parameter isn't valid).
注意:这个函数总是返回true(即使时区参数无效的情况下)。


example
案例

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

the output of the code above will be:
上述代码将输出下面的结果:

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template