I have a php datetime function that is used to insert the current date and time into mySQL database. However the date gives the right date but a wrong time any suggestion.
Below is the code.
/* Get Current Date and Time for the bookking_time field */
$booking_time=new DateTime();
$booking_time = $booking_time -> format("Y-m-d H:i:s");
// Create connection
$con = new mysqli($servername, $username, $password, $dbname , 3306);
if ($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}
//mysql_select_db("$database", $con);
$sql= "INSERT INTO data_centre_users (fisrt_name,last_name,request,purpose,description,booking_time,approved)
VALUES ('$first','$last','$request','$purpose','$description','$booking_time','$approval')";
if ($con->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
any suggestion to fix the problem