Using MySqli bind_param to Insert Date and Time Data
Inserting date and time values into MySQL columns using PHP mysqli and bind_param involves treating them like any other string. Here's how to do it:
$stmt = $mysqli->prepare('insert into foo (dt) values (?)');
Use the 's' format specifier to bind a string. For example, for a date-time value of '2009-04-30 10:09:00':
$dt = '2009-04-30 10:09:00'; $stmt->bind_param('s', $dt);
$stmt->execute();
By following this approach, you can insert date and time values into MySQL columns efficiently using mysqli and bind_param.
The above is the detailed content of How to Insert Date and Time Data into MySQL using mysqli bind_param?. For more information, please follow other related articles on the PHP Chinese website!