I am getting the date and time from user input and then trying to insert the given date and time into a datetime column in MySQL. This it doesn't seem to be working. However, when I insert NOW() it works fine.
I have the variables: $year, $month, $date, $hour, and $minute.
And this is what I am doing:
$i_date = "$year";
$month= sprintf("%02s", $month); // These add a leading zero to numbers less than 10
$i_date .= "$month";
$date = sprintf("%02s", $date);
$i_date .= "$date";
$hour = sprintf("%02s", $hour);
$i_date .= "$hour";
$minute = sprintf("%02s", $minute);
$i_date .= "$minute";
$i_date .= "00"; // These are for seconds.
This gives the me the correct format for the date. I have checked it by echoing it out and then trying to manually insert into the database and it works.
But when I try to insert $i_date into the datetime column via PHP, it does not accept it.
How can I correct this?
:and.or something like that here and there?