I got an output like this, I am doing it in php :
Tue Jul 12 09:48:44 2016
I want to convert it into like this :
2016-07-12 09:48:44
Use date()
function to change date time format and don’t forget to use strtotime()
date ("Y-m-d h:i:s",strtotime("Tue Jul 12 09:48:44 2016"))
You can try the below code
$date = 'Tue Jul 12 09:48:44 2016';
echo date('Y-m-d H:i:s',strtotime($date));
Output: 2016-07-12 09:48:44
I'd parse the input with createFromFormat:-
$dateInputString = "Tue Jul 12 09:48:44 2016";
//Convert the string from the format supplied to a date
$date = DateTime::createFromFormat('D M d H:i:s Y', $dateInputString);
//output the date in the required format
echo $date->format('Y-m-d H:i:s');