Home > Article > Backend Development > How to Insert Date and Time Data into MySQL using PHP mysqli and bind_param?
Binding Date and Time Columns with mysqli
Inserting date and time data into MySQL using PHP mysqli and bind_param requires treating them the same way as any other string. Here's how to do it:
<code class="php">$stmt = $mysqli->prepare('insert into foo (dt) values (?)'); $dt = '2009-04-30 10:09:00'; $stmt->bind_param('s', $dt); $stmt->execute();</code>
In this code:
The above is the detailed content of How to Insert Date and Time Data into MySQL using PHP mysqli and bind_param?. For more information, please follow other related articles on the PHP Chinese website!