如何设置date.timezone代码igniter使用php5.3 [英] How to set date.timezone for code igniter to work with php5.3

查看:156
本文介绍了如何设置date.timezone代码igniter使用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,代码igniter 2.0.0和Apache2.2。

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

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

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");

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

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代码igniter使用php5.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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