我已经获取了值,但是我不能检查两个日期是否相同。
表单和数据库日期。
我的代码:
$new_date = date('Y-m-d', strtotime($_POST['datet']));
$res =mysqli_query($con,"SELECT tdate FROM tablev1");
if($res) {
while($row = mysqli_fetch_assoc($res)) {
$date = $row['tdate']; // use your column name
$td=strtotime($date);
echo date("j F Y",$td);
if($new_date==$td) {
echo "Table booked";
}
}
}发布于 2016-10-11 14:47:44
在您的代码中,日期格式的strtotime没有错误,您不能从object($res)中获得结果。
警告的原因是strtotime没有获取任何参数。
$res =mysqli_query($con,"SELECT * FROM tablev1");
if($res) {
while($row = mysqli_fetch_assoc($res)) {
$date = $row['date']; // use your column name
$td=strtotime($date);
echo date("j F Y",$td);
}
}发布于 2016-10-11 15:02:25
请注意,mysqli_query()将返回资源id not result。为了获得结果,您需要使用mysqli_fetch_*函数,这里我使用mysqli_fetch_array()
<?php
$res = mysqli_query($con,"SELECT * FROM tablev1");
while ($row = mysqli_fetch_array($res)) {
echo date('j F Y',strtotime($row['yourDate'])); // change your column name
}
?>-将任何英文文本日期时间描述解析为Unix时间戳
https://stackoverflow.com/questions/39971672
复制相似问题