antonioribeiro / support

Support Classes
BSD 3-Clause "New" or "Revised" License
59 stars 49 forks source link

to_carbon helper alternateFormat issue. #26

Open cmoses1020 opened 4 years ago

cmoses1020 commented 4 years ago

$alternateFormat in to_carbon helper is used too late in the method and will sometimes be missed completely.

The date format m/d/Y comes out wrong when being passed to to_carbon because of this

to_carbon('06/02/2000', 'm/d/Y')->format('m/d/Y');
// outputs 02/06/2000

$value is caught by line 947

// Try to convert it using strtotime().
if (($date = strtotime($value)) !== false)
{
    return Carbon\Carbon::createFromTimestamp($date);
}

If $alternateFormat is used i believe createFromFormat() should come sooner in this method.