How could a string be formatted depending an am/pm value so it could then be passed through strtotime and date?
I have a form with two inputs and one select element.
- Hour (input) <- (String) from 1 through 12
- Minute (input) <- (String) from 0 through 59
- AM/PM (select) <- (String) am or pm
Need to insert to MySql type DATETIME which needs formatting to be current day + user selected time.
Possible String: ‘2:34:pm’ which for insert formatted to ‘2012-03-22 14:34:00’
I read possible duplicate question, but I believe was difference scenario.
Assuming your variables are named
$hour,$minute, and$ampm: