mardi 23 février 2021

Laravel 5 Convert Date String to Desired Date Format

I have a set of dates with different formats as below

3 Mar 2020
Mar 3, 2020
A1 -- this is obviously not a date but how can I escape to convert this to date format? 
1I

Code below doesn't work with A1 or 1I.

if (Carbon::createFromFormat("d M Y", $item)) {
    return "valid"; 
    //do my things
}
//if it's not date, then just ignore

Any shortest way to convert the correct date to my date format Y-m-d? And how can I escape from converting A1 and 1I? These lines should be ignored when comes to check the date format.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire