Welcome Guest, Not a member yet? Register   Sign In
Timezone settings problem in codeigniter
#1

[eluser]abdel[/eluser]
I am trying to setup CodeIgniter on my WAMP with PHP 5.3.5 and 2.0.2 CI. My "Hello World" application run successfully (I had only a controller and view). Next I added a Model test.php

Code:
class Hello extends CI_Model {

    function __construct() {    
        parent::__contruct();
    }
}
I instantiate the model in my controller as:

Code:
$this->load->model('Tests');
But I keep getting this error:

Quote:A PHP Error was encountered

Severity: Warning

Message: require_once(): 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 'Asia/Dubai' for '4.0/no DST' instead

Filename: models/hello.php

Line Number: 9

How do I resolve this error? I tried setting date.timezone property in php.ini. I also tried calling date_default_timezone_set method in index.php of CI.

I did go through CI forum but everybody seems to have fixed the issue by calling date_default_timezone_set. But when I call the method, I don't even get the error. Instead, I get an 500 server error response from Apache!

I get this error only when I invoke the controller that instantiate the model. For reference, here is my controller as well:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Hello extends CI_Controller {

    public function index()
    {
        $this->load->view('hello');
    }
    
    public function newfun()
    {
        
        $this->load->model('hello');
        echo 'Look at this!';
    }
}

?>

I get the issue only when i call: http://localhost/ci/index.php/hello/newfun

Please help. I am just getting started with CI.
#2

[eluser]toopay[/eluser]
[quote author="abdel" date="1303128619"]...I tried setting date.timezone property in php.ini.
[/quote]

Make sure you change it properly
Code:
; Defines the default timezone used by the date functions

date.timezone = Asia/Dubai
No semicolons or single quotes, and restart the webserver
#3

[eluser]abdel[/eluser]
Quote:; Defines the default timezone used by the date functions

date.timezone = Asia/Dubai

I tried this. With quotes and without quotes. It makes no difference! Is this some issue with my installation? The install instructions seems very straight forward. I just extracted the download zip file and moved to the web root and renamed the folder to "ci" for easy access!
#4

[eluser]toopay[/eluser]
Are you restarted your WAMPP service after changes that value? No, instalation process seems not an issue here. Its PHP issue actually, not related with CI or CI Instalation.
#5

[eluser]abdel[/eluser]
Yes.. I restarted the Apache server. Currently by php.ini have:
Code:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Dubai

; http://php.net/date.default-latitude
;date.default_latitude = 31.7667

; http://php.net/date.default-longitude
;date.default_longitude = 35.2333

; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333

; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333

and in my config.php found at ci/application/config folder has:
Code:
$config['time_reference'] = 'local';

When I call a controller method which doesn't reference any model.. it simply works fine! If I create a instance of the model.. it stops working! I have nothing except this in my hello.php (Model)

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class Hello extends CI_Model {

        function __construct()
        {
            parent::__construct();
        }
    }
?>
#6

[eluser]toopay[/eluser]
Abdel, remove the closing tags '?>' both in controller or model
#7

[eluser]abdel[/eluser]
Sad I removed the closing tags from controller and model. But still has the same effect after restart of the server.
#8

[eluser]WanWizard[/eluser]
Are you sure you've modified the correct php.ini?

If you do a
Code:
phpinfo();
in your controller, what does it say for 'date.timezone'?
#9

[eluser]abdel[/eluser]
I have only on installation of php.ini at C:\PF\PHP. I tried the phpinfo() and get correct value. ie Asia/Dubai!

Here is what I get in data section of the page:

date

date/time support enabled
"Olson" Timezone Database Version 2010.15
Timezone Database internal
Default timezone Asia/Dubai

Directive Local Value Master Value
date.default_latitude 31.7667 31.7667
date.default_longitude 35.2333 35.2333
date.sunrise_zenith 90.583333 90.583333
date.sunset_zenith 90.583333 90.583333
date.timezone Asia/Dubai Asia/Dubai
#10

[eluser]toopay[/eluser]
Are you autoload session library?




Theme © iAndrew 2016 - Forum software by © MyBB