Reputation:
I have the following
"end_time" represents datetime in unix format
$vouchers = DB::table('deals_sales')
->whereIn('status', [0, 1])
->where('end_time', '>=', strtotime("+5 day"))
->get();
What I'm trying to achieve is get all results that are going to end between now and next 5 days, but with my query I get even those that are going to expire in 10 days.
I just don't see the logic on how to get it.
Any ideas?
Thanks
Upvotes: 0
Views: 58
Reputation: 44526
Since you're using integer timestamps you might be looking for whereBetween
. Try the follwing:
$vouchers = DB::table('deals_sales')
->whereIn('status', [0, 1])
->whereBetween('end_time', [time(), strtotime("+5 day")])
->get();
This will get you the entries that have end_time
between now and the next 5 days.
Upvotes: 0