Carbon - ISO 8601 Date Format via JavaScript

2018-10-11T19:02:35.273Z ($date2) is generated in JavaScript with the following:

 console.log(new Date().toISOString());

I am having problem using Carbon to convert 2018-10-11T19:02:35.273Z to Y-m-d H:i:s format.

I get the following error:


Trailing data

There is no problem using Carbon::now()->toIso8601ZuluString() which has converted to our format (Y-m-d H:i:s): 2018-10-11 19:07:37

Is there a way to amend Carbon::createFromFormat() format to be compatible with new Date().toISOString() and Carbon::now()->toIso8601ZuluString()? I don't want to have different format for each one.

Using toIso8601ZuluString;

$date1 = Carbon::now()->toIso8601ZuluString();
$dateFormat1 = Carbon::createFromFormat("Y-m-d\TH:i:s\Z", $date1);
dump($dateFormat1->format("Y-m-d H:i:s"));

Output: 2018-10-11 19:07:37

Using new Date().toISOString() via Javascript

$date2 = "2018-10-11T19:02:35.273Z"; //Via new Date().toISOString(); in Javascript
$dateFormat2 = Carbon::createFromFormat("Y-m-d\TH:i:s\Z", $date2);
dump($dateFormat2->format("Y-m-d H:i:s"));

Error: Trailing data