1

This is the format I have:

Sunday, March 29 4:30 PM

This is the format I want:

2015-05-29 16:30:00

I tried:

Date('Y-m-d H:i:s', strtotime($dateTime));

But it does not work. Any help?

Rizier123
  • 58,877
  • 16
  • 101
  • 156
PHPWhisperer
  • 101
  • 1
  • 10
  • 1
    Do you simply want to change the format, or actually change the date from March 29th to May 29th as well? – Mark Baker Mar 29 '15 at 18:16

1 Answers1

3

This should work for you:

(Just use DateTime::createFromFormat)

$date = DateTime::createFromFormat("D, M d h:i A", "Sunday, March 29 4:30 PM");
echo $date->format("Y-m-d H:i:s");

output:

2015-03-29 16:30:00
Rizier123
  • 58,877
  • 16
  • 101
  • 156