Using Mysqli bind_param with date and time columns?

前端 未结 8 937
清歌不尽
清歌不尽 2020-12-08 06:14

How do you insert data into a MySQL date or time column using PHP mysqli and bind_param?

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 07:03

    I used the date( ) function and this solved me the problem.

    $stmt = $mysqli->prepare("INSERT INTO FOO (dateColumn) VALUES ?");
    // 6/10/2015 10:30:00
    $datetime = date("Y-m-d H:i:s", mktime(10, 30, 0, 6, 10, 2015));
    $stmt->bind_param("s", $datetime);
    $stmt->execute();
    

提交回复
热议问题