【发布时间】:2021-05-21 15:31:36
【问题描述】:
我的 PHP 代码一直使用 XAMPP 和 PHPmyadmin 处理日期。现在我想把所有东西(数据库和我的文件)放到我的服务器上,看起来除了我的日期之外一切都正常。 我尝试了多个代码,但我还没有找到合适的代码,我错过了什么?
这里是与“日期”相关的所有内容:
if(isset($_POST['submit'])){
$date = (isset($_POST['datum']) && !empty($_POST['datum'])) ? $_POST['datum'] : null;
$date = strtotime($date);
$date = date('d-m-Y', $date);
}
$currentDate = date('Y-m-d');
<input type="date" class="inputright" id="inputright" placeholder="Datum *" name="datum" required="required" value="<?php echo $currentDate;?>">
$query = " INSERT INTO bestellung (nr, datum, bestellid, wert, por, ebest, gebucht, geliefert, track, kunde_id)";
$query .= "VALUES ('$nr', '$date', '$bestellid', '$wert', '$por','$ebest', 'No','No', 'No', '$kunde_id' )";
以及我表中的日期: enter image description here
感谢任何帮助
【问题讨论】:
-
检查您的服务器数据库日期格式。
-
您的插入/更新字符串在哪里?
-
@Kashif 引号没有解决错误..
-
你的日期栏真的是
'd-m-Y'格式吗?可能不是。这不好。