0

Is there a way in PHP to convert the date time format from the one in the left to the one on the right?

1900-01-01T00:00:00-06:00 to 1900-01-01 00:00:00.000

2015-06-18T00:00:00-05:00 to 2015-06-18 00:00:00.000

As you see I don't want to keep the timezone and want to get rid of the T and I believe the one in the right also has milliseconds.

Jesus
  • 318
  • 1
  • 4
  • 17
  • A generic version to get you started: http://stackoverflow.com/questions/2754765/how-to-reformat-date-in-php – Marc B Sep 26 '16 at 21:46

1 Answers1

2

Since only the year month and day are pertinent, you can just use date_format to get that from your existing string, then concatenate your time to it, resulting in the string you're after.

date_format(new DateTime("1900-01-01T00:00:00-06:00"),"Y-m-d")." 00:00:00.000";
// 1900-01-01 00:00:00.000
Robert Wade
  • 4,918
  • 1
  • 16
  • 35