I am working on a school website that was working but is now having errors. The page attempts to insert a new exam into our database of exams, but on submission hits this error.
"Error SQLSTATE[HY000]: General error: 1411 Incorrect datetime value: '2:50 AM' for function str_to_date"
The code we are using to input the data is as follows
$sqlInsertExam = "INSERT INTO exam (name, quarter, date, location, state, possible_grade, passing_grade, duration, start_time, cutoff)
VALUES (:name, :quarter, :exam_date, :location, :state, :possible_grade, :passing_grade, :duration, STR_TO_DATE(:start_time, '%h:%i %p'), :cutoff)";
as you can see we are using %h:%i %p which as far as I know means in 12 hour format hr:min AM/PM. Which is what we are giving it. The only problem I can see is that the previous datetimes in the table are listed as military time in the form hr:mm:ss e.g. 14:00:00. But I am unsure if that is what is causing this error