I was trying to convert a datetime to another format.
$original_value = "10-30-2013 14:19:12";
It is in m-d-Y H:i:s format and i want to convert it into Y-m-d H:i:s to save it to the database.
I've already tried the ff:
$original_value = "10-30-2013 14:19:12";
$date = new DateTime(strtotime($original_value));
echo $date->format('Y-m-d H:i:s');
output: 2013-10-16 14:31:19
// which is wrong since it gets the current datetime value
$original_value = "10-30-2013 14:19:12";
echo date('Y-m-d H:i:s', strtotime($original_value))
output: 1970-01-01 08:00:00
// which is also invalid
How can i do this kind of thing. Thanks for the help.