首页 > 解决方案 > Mysql now () + INTERVAL 1 DAY 在实时服务器上返回 0000-00-00 00:00:00

问题描述

我正在做一个项目。我刚刚将它上传到我的实时服务器。当用户发布工作时,我使用 mysql now() + INTERVAL 和工作交付时间来设置过期时间,这样我就可以选择过期的工作而不选择所有工作。这在我的本地开发环境中工作正常,但在现场它会在 db 中插入 0000-00-00 00:00:00。

有什么建议么?

$job['delivery_time'] = 8; // can have a number from 1 to 29

$sql = "INSERT INTO jobs(job_id, posted_by, title, category_id, description, required_freelancers, budget, delivery_time, job_expiration, date_posted, updated_at) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, now() + INTERVAL " . $job['delivery_time'] . " DAY, ?)";
$stmt = mysqli_stmt_init($db);
mysqli_stmt_prepare($stmt, $sql);

$current_time = date('U');
mysqli_stmt_bind_param($stmt, 'sssisisiii', $job['id'], $user_id, $job['title'], $job['category'], $job['description'], $job['required_freelancers'], $job['budget'], $job['delivery_time'], $current_time, $current_time);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);

标签: phpmysqlsqldatetime

解决方案


推荐阅读