php时间显示相差8个小时_php 日期时差8小时间解决方法

程序中添加时间的初始化语句:“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)
parameter

参数

description

描述

timezonerequired. 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"));?>

the output of the code above will be:

上述代码将输出下面的结果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值