PHP convert separate date and time strings into single datetime
-
26-12-2019 - |
Question
I have two separate strings for date and time formatted something like: 14/04/2014
and 01:15 PM
I would like to convert these to a datetime formatted as Y-m-d H:i:s
Any idea how I go about this??
Solution
$date = DateTime::createFromFormat('d/m/Y h:i A', '14/04/2014'.' '.'01:15 PM');
echo $date->format('Y-m-d H:i:s');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow