【问题标题】:time zone error after installation a script [duplicate]安装脚本后时区错误[重复]
【发布时间】:2016-03-19 00:58:28
【问题描述】:

我收到一条错误消息 ----------

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/user/public_html/cdemo/_include/lib/lib.php on line 73

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/user/public_html/cdemo/_include/lib/lib.php on line 74



Error: E_WARNING
URL: http://mywebsite.com/demo/
File: /home/user/public_html/cdemo/_include/lib/db_common.php
Line: 69
Message: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.

Call stack:

File: /home/user/public_html/cdemo/_include/lib/db_common.php (Line: 69)
Function: date

File: /home/user/public_html/cdemo/_include/core/start.php (Line: 199)
Class: DB_Common
Function: connect

File: /home/user/public_html/cdemo/_include/core/main_start.php (Line: 12)
Function: include

File: /home/user/public_html/cdemo/index.php (Line: 15)
Function: include

如何解决这个问题??

【问题讨论】:

  • $sql = 'SET SESSION sql_mode = "", NAMES "utf8", SESSION collat​​ion_connection = "utf8_unicode_ci", time_zone = "Indian/Cocos' . date('P') . '" ';
  • db_common.php 文件中我的 database_common 目录中有一行

标签: php database timezone server cpanel


【解决方案1】:

有两种方法可以解决这个问题:

  1. 在你的脚本(或你的mvc框架的入口文件)的顶部使用内置函数date_default_timezone_set(timezone_of_your_place)。您可以在 timezone_list 中找到代表您所在位置的时区的常量。

  2. php.ini修改配置项date.timezone = your_timezone

这两者的区别在于,方式一会立即生效,但只在该脚本的生命周期内生效,方式二会在重新加载php配置文件后影响所有php脚本的行为。

【讨论】:

  • b_common.php 行:46 消息:无法执行查询:未知或不正确的时区:'Asia/Calcutta+05:30' SET SESSION sql_mode = "", NAMES "utf8" , SESSION collat​​ion_connection = "utf8_unicode_ci", time_zone = "Asia/Calcutta+05:30"
  • 现在我从这一行中删除并放入 php.ini 并开始工作。
猜你喜欢
  • 2019-09-04
  • 1970-01-01
  • 2023-01-20
  • 1970-01-01
  • 1970-01-01
  • 2015-09-25
  • 1970-01-01
  • 1970-01-01
  • 2020-11-26
相关资源
最近更新 更多