php - 使用 PHP/PDO 将 future 10 分钟添加到 MySQL 数据库中

标签 php mysql time pdo

我想向数据库中添加一行, future 时间为“x”(每行不同)。我已经查看了所有教程/帮助/我可以通过谷歌找到的任何内容,但似乎没有任何帮助。

据我所知,最好的方法是使用 MySQL。

SELECT ADDTIME(now(), '00:10:00')

但我如何才能真正做到这一点:

$new_row = $db->prepare("INSERT INTO table (field1, field2, time) VALUES(?, ?,?)");

$new_row->execute(array($field1, $field2, $timeintenminutes)) or dieWithDBError($new_row);

最佳答案

未经测试,但你试过吗:

$new_row = $db->prepare("INSERT INTO table (field1, field2, time) VALUES(?, ?, ADDTIME(NOW(), '00:10:00'))");
$new_row->execute(array($field1, $field2)) or dieWithDBError($new_row);

关于php - 使用 PHP/PDO 将 future 10 分钟添加到 MySQL 数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6195332/

相关文章:

php - 在动态类名的开头添加反斜杠

MySQL 选择月的最后一天存在于表中

android - 如果 Android 中的时区是 Pacific/Tongatapu,Time.toMillis(false) of 1/1/1941 总是返回 -1

python - 0-23 小时军用时钟到标准时间 (hh :mm)

php - 在 PHP 中使用命名空间和自动加载从变量创建对象

php - UPS 运输教程 (PHP)

mysql - 错误#1064 : phpMyAdmin import showing html errors in a MYSQL database - why html?

mysql - 如何根据存储过程参数制作动态数据透视表

java - 如何在 Java 中以微秒精度测量时间?

php - 使用php mysql插入和更新数据库