I have a uploaded_at column in database having type as timestamp.
$from = date("d-m-Y", strtotime("-2 months"));
$data = Post::where('uploaded_at' , '>' , $from)->paginate(20);
This piece of code is giving all the data from the post table where I needed only the last 2 months post.
Y-m-d. Sorry, that's what Tushar already wrote below.postsWHERE uploaded_at > '2020-1-1' ]...TIMESTAMP, I suppose you have to useY-m-d 00:00:00including time information, see dev.mysql.com/doc/refman/8.0/en/…