Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

unk's avatar
Level 1

How do I extract this data from mysql table in a view?

Hello,

I want to resolve the problem with the script. I thought I'd leave the date like this, but how do I extract it in view? https://imgur.com/d9UT9A8 This date is stored in mysql properly. But in my controllers date is format as:

date('Y-m-d'))

How to change to show like here https://imgur.com/d9UT9A8 ?

0 likes
2 replies
kokoshneta's avatar

If your controller formats it as Y-m-d (that is, throwing away the time information), there is no way to get the hours, minutes and seconds back. They’re lost forever. Just like you can’t get the timestamp back if you write a date and time down on a piece of paper, then tear off the time and burn it.

If you want to display it in full in your view, why is your controller changing it to a string that only contains some of the information?

Assuming the column in your database is a datetime column and your Eloquent model is properly set up, the date should be a Carbon date object, which you can format in about ten million ways as you see fit. Just pass the Carbon date object directly to the view without changing it, and then decide in your view how you want to format it.

2 likes
jlrdw's avatar

You can use formatting in a view.

2 likes

Please or to participate in this conversation.