Catch possible invalid format exception & return "Invalid date!"
This commit is contained in:
parent
7c01b3bb64
commit
b88533d3d2
1 changed files with 6 additions and 3 deletions
|
|
@ -99,10 +99,13 @@ trait MakesDates
|
|||
|
||||
public function translateDate($date, $format, $locale)
|
||||
{
|
||||
|
||||
Carbon::setLocale($locale);
|
||||
return Carbon::parse($date)->translatedFormat($format);
|
||||
|
||||
try {
|
||||
return Carbon::parse($date)->translatedFormat($format);
|
||||
} catch(\Exception $e) {
|
||||
return 'Invalid date!';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue