Laravel and the formatting of dates

2

Gentlemen I am making a query to a table with Eloquent ... and between the fields that I want to consult this one of date, as I do so that in full consultation to bring the date formatted? Ex:

$consulta=Ejemplo::select('fecha')->find($id);

I am looking for the date field but it is in mm-dd-yyyy, I want to present it as dd-mm-yyyy as it is done?

    
asked by jose angarita 20.02.2018 в 15:04
source

1 answer

1

The dates in Laravel are converted (usually) to Carbon's instances, at least in the recent versions, in theory you should simply use the format() method in the Carbon instance, that is, in the field as such:

$consulta->fecha->format('d-m-Y');
    
answered by 20.02.2018 в 15:18