php - How to split a string in the controller of codeigniter? -
i using codeigniter framework. getting date view.i want send them 2 fields. "2016-06-19" 1 field , "2015-06" field. how can done?? if has idea me.
here controller function.
function add() { $reservation_model = new reservation_model(); $reservation_service = new reservation_service(); $newdate=$this->input->post('date',true); $splitted= split("-", $newdate, 1); $reservation_model->set_date(trim($this->input->post('date',true))); $reservation_model->set_date_half($splitted); $reservation_model->set_title(trim($this->input->post('selected_hall', true))); $reservation_model->set_type(trim($this->input->post('selected_time', true))); $reservation_model->set_description(trim($this->input->post('name', true))); $reservation_model->set_advanced_payment_status(trim($this->input->post('optionsradios', true))); //$reservation_model->set_advanced_payment_status(trim($this->input->post('no', true))); $reservation_model->set_paid_amount(trim($this->input->post('paid_amount', true))); $reservation_model->set_fax(trim($this->input->post('fax', true))); $reservation_model->set_telephone_number(trim($this->input->post('telephone', true))); $reservation_model->set_address(trim($this->input->post('address', true))); $reservation_model->set_menu_no(trim($this->input->post('selected_menu_number', true))); $reservation_model->set_menu_price_per_plate(trim($this->input->post('menu_price', true))); $reservation_model->set_is_deleted('0'); //$this->db->last_query(); echo $reservation_service->add_reservation($reservation_model); }
date original date. should "2015-06-19". date_half other date field. should "2015-06"
it more general php question ci question. date , strtotime functions.
$splitted = date('y-m', strtotime($this->input->post('date',true)));
Comments
Post a Comment