如何设置代码点火器的date.timezone来处理php5.3 [英] How to set date.timezone for code igniter to work with php5.3

查看:168
本文介绍了如何设置代码点火器的date.timezone来处理php5.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当php.ini中的date.timezone被注释掉时,它给了我:

When date.timezone in php.ini is commented out, it gives me:


遇到PHP错误

A PHP Error was encountered

严重性:警告

消息:main():
不安全依赖于系统的时区
设置。您需要 使用
date.timezone设置或
date_default_timezone_set()函数。
如果您使用任何方法
,并且您仍然收到此
警告,那么您很可能拼错了
时区标识符。我们为'-8.0 / no
DST'选择
'America / Los_Angeles'

Message: main(): 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 'America/Los_Angeles' for '-8.0/no DST' instead

文件名:controllers / helloworld.php

Filename: controllers/helloworld.php

行号:2

当我有

date.timezone = "America/Los_Angeles"

它给了我这个:


服务器错误网站遇到
一个错误,同时检索
http://localhost/ci/index.php/helloworld
可能会维护或
配置不正确。这里有一些
的建议:稍后重新加载此网页
。 HTTP错误500(内部服务器
错误):服务器
尝试完成请求时遇到一个意外的条件是

Server error The website encountered an error while retrieving http://localhost/ci/index.php/helloworld. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this web page later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

我正在使用php5.3,代码点火器2.0.0和Apache2.2。任何人也有这个问题?

I am using php5.3, code igniter 2.0.0, and Apache2.2. Anyone has this problem too?

更新1:
我尝试加载一个没有代码点火器的test.php,其中test.php的前3行是

Update 1: I tried loading a test.php without code igniter, where the first 3 lines of test.php is

date_default_timezone_set('America/Los_Angeles');
echo date("l j \of F Y h:i:s A");

它工作正常,不同的时区也可以正常工作。
所以我怀疑问题是从代码点燃器...
任何人在这里使用代码点火器?

And it works fine, different timezones also works fine too. So I suspect the problem is from code igniter... Anyone using code igniter here?

推荐答案

如果您使用GoogledCodeIgniter PHP 5.3,您将很快找到这篇文章:)

If you Googled "CodeIgniter PHP 5.3" you would have found this article pretty quickly :)

http://philsturgeon.co.uk/blog/2009/12/CodeIgniter-on-PHP-5.3

要解决此问题,您只需编辑CodeIgniter应用程序的主index.php:

To fix this, you only need to edit the main index.php for your CodeIgniter application:

if( ! ini_get('date.timezone') )
{
   date_default_timezone_set('GMT');
} 

此修改是您可能需要为任何CodeIgniter应用程序运行的PHP 5.3,可以轻松地修改为您当地的时区。有关PHP手册中此处支持的时区的完整列表。

This modification is something you will probably need to make for any CodeIgniter application running on PHP 5.3 and can easily be modified to your local timezone. There is a full list of supported timezones in the PHP manual here.

这篇关于如何设置代码点火器的date.timezone来处理php5.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆