加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP时区未设置

发布时间:2020-12-13 18:12:11 所属栏目:PHP教程 来源:网络整理
导读:首先,我无法访问网络服务器中的php.ini. 在我的本地服务器中,我将date.timezone =“Europe / Lisbon”放入我的php.ini中. 是否可以在.htaccess中更改此内容?或者,替代方案是什么? 目前我在phpmailer()的web服务器中收到此错误: Strict Standards: date():
首先,我无法访问网络服务器中的php.ini.

在我的本地服务器中,我将date.timezone =“Europe / Lisbon”放入我的php.ini中.

是否可以在.htaccess中更改此内容?或者,替代方案是什么?

目前我在phpmailer()的web服务器中收到此错误:

Strict Standards:  date(): It is not safe to rely on the system's timezone settings. ....
第二个想法,ini_set可能不是最好的方式.显然E_STRICT标准说你应该使用date_default_timezone_set.

尝试以下方法:

date_default_timezone_set('Europe/Lisbon');

$tz = date_default_timezone_get();

有关此问题的更多信息,请点击此处:
http://answers.google.com/answers/threadview/id/739376.html

这里是default_timezone函数:
http://us2.php.net/manual/en/function.date-default-timezone-set.php

编辑:我在浏览github时发现了这个小宝石.

// has to be set to reach E_STRICT compatibility,does not affect system/app settings
date_default_timezone_set(date_default_timezone_get());

这似乎是最好的解决方案.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读