-1

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
Marcin Kosiński
  • 7,578
  • 5
  • 49
  • 95
minu
  • 75
  • 2
  • 2
  • 9

3 Answers3

2

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"))
Dhara Parmar
  • 7,791
  • 1
  • 14
  • 25
0

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

Arun
  • 3,496
  • 7
  • 41
  • 78
0

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');
Ian White
  • 11
  • 3