我正在尝试将datetime值插入到我的数据库中,但是当我执行查询时,插入的值为: " 1970-01-01 00:00:17" 但是当我插入日期时,我会得到用户插入的日期。 这是我转换时间的地方:
$date = date("Y-m-d",strtotime(str_replace('/','-',$_POST["date"])));
$s_time =date("Y-m-d H:i:s",$_POST["s_time"]);
$e_time = date("Y-m-d H:i:s",$_POST["e_time"]);
$result = $dbF -> InsertNewEvent($manager,$sport,$date,$s_time,$e_time,$place,$lon,$lat,$event_type,$gen,$min_age,$max_p,$sched);
这是查询:
function InsertNewEvent($manager,$sport,$date,$s_time,$e_time,$place,$lon,$lat,$event_type,$gen,$min_age,$max_p,$sched){
$result = mysqli_query($this->con, "INSERT into event(manager_id,kind_of_sport,event_date,start_time,end_time,address,longtitude,latitude,private,gender,min_age,max_participants,current_participants,scheduled,event_status)
VALUES ('$manager','$sport','$date','$s_time','$e_time','$place','$lon','$lat','$event_type','$gen','$min_age','$max_p','1','$sched','1')") or die (mysqli_error($this->con));
return $result;
}
为什么我得到这个值?
答案 0 :(得分:0)
我将我的代码更改为此代码并得到了解决,谢谢。
$s_time =$date." ".$_POST["s_time"];
$e_time = $date." ".$_POST["e_time"];
$s_time =date("Y-m-d H:i:s",strtotime($s_time));
$e_time = date("Y-m-d H:i:s",strtotime($e_time));