Soo's avatar
Level 2

show the date from timestamps column

in react i can show just the date in the column $table->timestamps(); i just want to get just the date with any time how ?

0 likes
1 reply
tykus's avatar

The timetamps method will create two columns on the database table; specifically the created_at and updated_at columns. Your Eloquent model will automatically cast these columns as Carbon instances and these will be serialized in the format Y-m-d H:i:s - however, you can override this default format in the Model class in a couple of different ways.

Alternatively, you can create an Eloquent API Resource and format the relevant column there.

It would be easier to make an appropriate suggestion if we understand how you are passing the data from your Laravel applocation to the React application.

Please or to participate in this conversation.