How can I check that my string is a valid date ("2018-01-01").
Is there a simple way, or do I need to do something like this:
if (Carbon::createFromFormat('YOUR DATE FORMAT', $stringVariable) !== false) {
// valid date
}
How can I check that my string is a valid date ("2018-01-01").
Is there a simple way, or do I need to do something like this:
if (Carbon::createFromFormat('YOUR DATE FORMAT', $stringVariable) !== false) {
// valid date
}
$timestamp = strtotime($date);
return $timestamp ? $date : null ;