我做错什么了?尝试将date time插入到我的数据库中时,所有字段都工作,只是日期时间不起作用。我试了好几个小时,什么都没用。
看法
<fieldset>
<legend>Account Information</legend>
<?php
echo form_open('banks/create_bank');
echo form_input('bank_name', set_value('bank_name', 'Account Name'));
echo form_input('interest', set_value('interest', 'Interest'));
echo form_input('start_amount', set_value('start_amount', 'Starting Balance'));
echo form_input('length', set_value('length', 'Length'));
echo form_dropdown("<type ='date' name='start_date'>") ;
// echo form_input("<type ='date' name='start_date'>") ;
// echo form_checkbox("<type ='date' name='start_date'>") ;
// echo form_fieldset("<type ='date' name='start_date'>") ;
// echo form_multiselect("<type ='date' name='start_date'>") ;
echo form_submit('submit', 'Add Bank ')
?>
</fieldset>
模型
$new_bank_acc_insert_data = array(
'bank_name' => $this->input->post('bank_name'),
'interest' => ($this->input->post('interest') / 100),
'start_amount' => $this->input->post('start_amount'),
'length' => $this->input->post('length'),
'start_date' => $this->input->post('start_date'),
'mem_id' => $this->session->userdata('id')
);
最佳答案
改变
$new_bank_acc_insert_data = array(
'bank_name' => $this->input->post('bank_name'),
'interest' => ($this->input->post('interest') / 100),
'start_amount' => $this->input->post('start_amount'),
'length' => $this->input->post('length'),
'start_date' => $this->input->post('start_date'),
'mem_id' => $this->session->userdata('id')
);
到
$new_bank_acc_insert_data = array(
'bank_name' => $this->input->post('bank_name'),
'interest' => ($this->input->post('interest') / 100),
'start_amount' => $this->input->post('start_amount'),
'length' => $this->input->post('length'),
'start_date' => date('Y-m-d H:i:s',strtotime($this->input->post('start_date'))),
'mem_id' => $this->session->userdata('id')
);