0

I'm having a date format like this:

2010-09-21T00:00:00+03:00

how can i convert it to 'Y-m-d H:i:s' format?

I've tried following code but I don't think it's working:

$date = new DateTime('2010-09-21T20:00:00+03:00');
$status_date = $date->format('Y-m-d H:i:s');

It prints time like this: 2010-09-21 20:00:00

ÛmÄîr MÄlîk
  • 453
  • 2
  • 10
  • 23

1 Answers1

1

It prints exactly want you want ! So what's wrong ?

You can also use Carbon and to like this :

Carbon::parse('2010-09-21T00:00:00+03:00')->toDateTimeString();

UPDATE

Be careful, you said you want midnight but you wrote 8pm in your php !

Community
  • 1
  • 1
FabienChn
  • 938
  • 10
  • 17