-2

This is simple to some;

I got the time: June, 18 2021 21:33

How do I convert into 2021-06-18 21:33:00 in PHP.

I tried:

$send_time = "June, 18 2021 21:33";
    
$date = Carbon::parse($send_time);

echo $date->format('Y-m-d h:i:sa');

Then got Could not parse 'June, 18 2021 21:33': DateTime::__construct(): Failed to parse time string (June, 18 2021 21:33) at position 6 (1): Unexpected character

Qwerty
  • 33
  • 6

1 Answers1

0

That datetime is not in any standard format. You're going to have to create your own format to pass in:

$date = Carbon::createFromFormat('F, d Y H:i', $send_time);

See https://www.php.net/manual/en/datetime.format.php for all of the date format characters

aynber
  • 22,380
  • 8
  • 50
  • 63