Answer the question
In order to leave comments, you need to log in
How to calculate how many users were created for the current and last week, but the week is from Sunday to Sunday?
Good afternoon. I made it to count for the current week like this:
$current_week = User::whereDate('created_at', '>=', date('Y-m-d H:i:s', strtotime('-7 days')))->count();
$previous_week = User::whereDate('created_at', '<', date('Y-m-d H:i:s', strtotime('-7 days')))
->whereDate('created_at', '>=', date('Y-m-d H:i:s', strtotime('-14 days')))->count();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question