How to insert values from JQuery datepicker to MySQL date datatype using Codeigniter?

后端 未结 5 886
一整个雨季
一整个雨季 2021-02-09 18:19

i can\'t insert the values from my JQuery Datepicker to my MySQL database with Date datatype. how will i convert string to date datatype? im using Codeigniter with MVC. here\'s

5条回答
  •  梦毁少年i
    2021-02-09 18:45

    Your controller should look like this:

    {
        $date = $this->input->post('dob');
    
        $data = array(
            'FirstName' => $this->input->post('fname'),
            'DateofBirth' => date('Y-m-d', strtotime($date))
        );
    
        $this->site_model->add_record($data);
        $this->index();
    }
    

    I think this suits you better

提交回复
热议问题