【发布时间】:2019-11-03 16:33:39
【问题描述】:
我在输入帖子时想计算日期范围时遇到问题。 但我的代码有错误:
Object of class DateInterval could not be converted to string
这是我的代码
$id_barang = $this->input->post('id_barang');
$id_rak = $this->input->post('id_rak');
$id_tf = $this->input->post('id_tf');
$id_user = $this->input->post('id_user');
$qty_outbound = $this->input->post('qty_outbound');
$tgl_outbound = $this->input->post('tgl_outbound'); // date out
$tgl_tf = $this->input->post('tgl_tf'); // date in
$tanggal = new DateTime($tgl_tf);
$today = new DateTime($tgl_outbound);
$selisihnya = $today->diff($tanggal);
$selisihnya->d = $this->input->post('selisih');
$data_insert = array(
'jenis' => 'outbound',
'id_barang' => $id_barang,
'id_rak' => $id_rak,
'id_tf' => $id_tf,
'id_user' => $id_user,
'qty_outbound' => $qty_outbound,
'tgl_outbound' => $tgl_outbound,
'tgl_tf' => $tgl_tf,
'selisih' =>$selisihnya
);
【问题讨论】:
标签: php codeigniter date