0

in variable $data['report_time'] it saving 00:00:14 tight now as per Indian time is 2:36 PM so Why it saving wrong time in the database please help me How can I resolve this error.

Codeigniter:

if(!$this->input->is_ajax_request()){
    show_404();
}
else{
    $data['address'] = $this->input->post("address");
    $data['lat'] = $this->input->post("lat");
    $data['long'] = $this->input->post("long");
    $data['pet_id'] = $pet_id;
    $data['user_id'] = $this->data['userdetails'][0]['id'];
    $data['report_date'] = date("Y-m-d");
    $data['report_time'] = date("H-i-s");
    $table = 'pet_report';
    $status = $this->Common_model->insert($table, $data);
    echo $status;
}
shah rushabh
  • 41
  • 1
  • 2
  • 9
  • http://stackoverflow.com/questions/31309536/how-to-set-time-zone-in-codeigniter –  May 07 '17 at 11:27

3 Answers3

0

Check server timing where you installed your mysql

Chinnu
  • 117
  • 2
  • 8
0

ok, I resolved this question myself here is a problem.

if(!$this->input->is_ajax_request()){
    show_404();
}
else{
    $data['address'] = $this->input->post("address");
    $data['lat'] = $this->input->post("lat");
    $data['long'] = $this->input->post("long");
    $data['pet_id'] = $pet_id;
    $data['user_id'] = $this->data['userdetails'][0]['id'];
    $data['report_date'] = date("Y-m-d");
    $data['report_time'] = date("H:i:s");
    $table = 'pet_report';
    $status = $this->Common_model->insert($table, $data);
    echo $status;
}

I replaced operator - with : in $data['report_time'];

shah rushabh
  • 41
  • 1
  • 2
  • 9
0

Set default timezone in your index.php of codeigniter folder

date_default_timezone_set('Asia/Kolkata');
Rafiqul Islam
  • 1,636
  • 1
  • 12
  • 25