My problem: when I combine my Jquery datepicker calendar input and the drop downs I put beside it to capture hours, minutes, and AM/PM I can’t get the proper date to print out.
Here is my php code:
echo protect($_POST['truck_arrive'])." - truck arrive<br>";
echo protect($_POST['truck_arrive_hours'])." - truck arrive hours<br>";
echo protect($_POST['truck_arrive_mins'])." - truck arrive mins<br>";
echo protect($_POST['truck_arrive_ampm'])." - truck arrive ampm<br>";
$truck_arrive_comb = protect($_POST['truck_arrive']).protect($_POST['truck_arrive_hours']).protect($_POST['truck_arrive_mins']).protect($_POST['truck_arrive_ampm']);
echo $truck_arrive_comb." - truck arrive combination<br>";
echo strtotime($truck_arrive_comb)." - truck arrive combination string to time<br>";
echo date("Y-m-d h:i:s",strtotime($truck_arrive_comb))." - truck arrive combination string to time date format<br>";
//$truck_arrive = date("Y-m-d h:i:s",strtotime($truck_arrive_comb));
$truck_arrive = date("Y-m-d h:i:s",strtotime(protect($_POST['truck_arrive'])));
echo $truck_arrive." - truck arrive date format<br>";
and it outputs this:
01/16/2013 - truck arrive
01 - truck arrive hours
04 - truck arrive mins
AM - truck arrive ampm
01/16/20130104AM - truck arrive combination
- truck arrive combination string to time
1969-12-31 07:00:00 - truck arrive combination string to time date format
2013-01-16 12:00:00 - truck arrive date format
This is a simplification of what you can use, just replace hard coded values with appropriate
$_POST:WIll need to modify if timezone needs to be considered.
An alternate approach is to parse the time and date strings into same format as above output and pass that to
strtotime()or simply match output thatdate()creates using the strings