Gmdate () returns 2 different results in 2 different controllers (codeigniter)

I have a situation where I use the php gmdate () function in two different codeigniter controllers. Controllers return a 6-hour difference with exactly the same calls.

Below is a controller that returns the correct GMT date and below, which is at a distance of 6 hours. Hope this is just something on my part. Thanks in advance for any help.

    public function update_current_user($session_id){
    $this->load->helper('date');
    $this->load->helper('url');

    $currentURL = base_url().uri_string();

    $updateData = array(
            'id'=>$session_id   ,
            'last_updated'=>gmdate("Y-m-d H:i:s",time()),   
            'current_url'=> $currentURL
        );
    $this->db->where('id',$session_id);
    $this->db->update('current_visitors', $updateData);
    return true;
}

Below is the one where he returns for 6 hours.

    public function initiate_chat($id,$name)
{
    $this->load->helper('date');
    $this->load->helper('url');

    $currentURL = base_url().uri_string();

    $updateData = array(
            'id'=>$id   ,
            'last_updated'=>gmdate("Y-m-d H:i:s",time()),
            'chat_requested_time'=>gmdate("Y-m-d H:i:s",time()),    
            'requested_chat'=>1,    
            'name'=>$name,
        );
    $this->db->where('id',$id);
    $this->db->update('current_visitors', $updateData);
    return $name;           
}   
+4
source share
2 answers

,   date_default_timezone_set ( 'GMT'); , . , . ,

date_default_timezone_set('GMT');
$curTime = gmdate('H:i:s',time());

, GMT.

+1

, Codeigniter PHP 5.

php.ini , Phil Sturgeon, ,

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

0

Source: https://habr.com/ru/post/1525308/


All Articles