$date = '20200727';
$formats = ['Y-m-d', 'Y/m/d', 'Ymd'];
$dateObj = null;
foreach ($formats as $format) {
try{
if ($dateObj = Carbon::createFromFormat($format, $date)){
break;
}
} catch (InvalidArgumentException $e) {
Log::debug('date', [$dateObj]); // It's null
}
}