笨。如何在表int()列中插入带时间戳格式的字符串值

时间:2014-08-08 12:46:30

标签: php mysql codeigniter

我希望发送日期,例如" 12.03.2014"在int列的数据库中 在控制器日期其输入类型文本。

$val = $this->backend->form_rules();
    if ($val->run()) {
        $todb = $this->backend->form_todb();
        $id = $db->add_newsone($todb);
        redirect("backend/news/edit/$id");
    }

我如何将我的$ todb [' date']更改为时间戳格式并发送到int(11)列?

2 个答案:

答案 0 :(得分:0)

如果您的日期存储在$todb['date'],您可以:

$date = new Datetime($todb['date']);
$todb['date'] = $date->getTimestamp();

希望这有帮助!

答案 1 :(得分:0)

我认为你可以使用strtotime:

strtotime("12.03.2014");