mercredi 30 novembre 2016

Laravel - Get data last 24 hours, 1 week or 1 month

So I'm trying to grab only data which are in last 24 hours, 1 week, 1 month. I have working code, but if I get it correctly it's "other way". By that I mean, If date is at the moment 30-Nov-2016 and I set the Data value to 1-Dec-2016, then the 24 Hour one still grabs the information, but it shouldn't. If date is 30-Nov-2016 and I set it to 28-Nov-2016, then the 24 Hour one doesn't grab it. For me It sounds like it's backwards. I hope the explanation is understandable.

$getItemsOneDay = Deposit::where('steam_user_id',0)->where('status', Deposit::STATUS_ACTIVE)->where('created_at', '>', Carbon::now()->subMinutes(1440))->get();
$getItemsOneWeek = Deposit::where('steam_user_id',0)->where('status', Deposit::STATUS_ACTIVE)->where('created_at', '>', Carbon::now()->subMinutes(10080))->get();
$getItemsOneMonth = Deposit::where('steam_user_id',0)->where('status', Deposit::STATUS_ACTIVE)->where('created_at', '>', Carbon::now()->subMinutes(43200))->get();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire