A
A
Alexander2017-03-03 20:38:37
Laravel
Alexander, 2017-03-03 20:38:37

How to display records of current date in laravel?

There is a table in a DB in it fields timestamps ()
How to deduce only those records which are created today. As well as for the current year.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
hopeful_romantic, 2017-03-03
@hopeful_romantic

There is a great tool for working with dates
carbon.nesbot.com/docs

D
Dmitry Chekanov, 2017-03-03
@LanDer931

Model::query()->where('created_at','>',Carbon::today())->get();
Read the Carbon documentation.

S
Sergey, 2020-01-09
@SVZhidkow

Just for future generations

// Сегодня
$q->whereDate('created_at', Carbon::today()->toDateString());

// Год
$q->whereYear('created_at', Carbon::today()->year);

Even more interesting in the documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question