Search code examples
codeignitercodeigniter-2

Codeigniter showing problem with date function


I want to insert values into db. I have a table as registration_patients. My code is:

$data = array(
    'patients_first_name' => $this->input->post('first_name'),
    'patients_last_name' => $this->input->post('last_name'),
    'patients_email' => $this->input->post('email'),
    'patients_password'=> $this->input->post('password'),
    'patients_birth_date'=> date('Y-m-d', strtotime($this->input->post('day') . "-" .$this->input->post('month') . "-" . $this->input->post('year'))),
    'patients_sex'=> $this->input->post('sex'),
    'patients_telephone'=> $this->input->post('telephone'),
    'patients_codice_fiscale'=> $this->input->post('codice_fiscale'),
    'account_active'=> 0
    );
    return $this->db->insert('registration_patients', $data);

Now it is inserted values into database bus showing some error and warning like that

A PHP Error was encountered

Severity: Warning

Message: strtotime(): 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 'Europe/London' for 'BST/1.0/DST' instead

Filename: models/doctors_model.php

Line Number: 22 and A PHP Error was encountered

Severity: Warning

Message: date(): 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 'Europe/London' for 'BST/1.0/DST' instead

Filename: models/doctors_model.php

Line Number: 22


Solution

  • In your root_folder/index.php write date_default_timezone_set('America/New_York'); and see if the problem is solved or not. Here is the link of available timezones.