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

KikoLdasd's avatar

Query by date if I have time string MYSQL

Hello, I have a database where created_at is saved in the genre 1535717887 =>31/08/2018, 15:18:07 How could I retrieve the data after a month and a year for example if created_at is saved like this

0 likes
5 replies
KikoLdasd's avatar

@Snapey Yes.

In my database my created_at is saved in a string like this 1535717887

And I would like to make a query to retrieve all the data from February 2022, but I don't really know how I could do that if the time is saved like this. And above I gave an example of how the time is if I convert that string into time

Snapey's avatar

@KikoLdasd User whereBetween and pass the start and end dates.

Model::whereBetween('created_at',['2022-02-01 00:00:00', '2022-03-01 00:00:00' ])->get();
Snapey's avatar

@KikoLdasd ok the process is the same.

Select from tablename where between('date1', 'date2')

Please or to participate in this conversation.