Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

get recoed between two datetime laravel

public function scopeCreatedBetweenDates($query, array $dates)
{
    $start = ($dates[0] instanceof Carbon) ? $dates[0] : Carbon::parse($dates[0]);
    $end   = ($dates[1] instanceof Carbon) ? $dates[1] : Carbon::parse($dates[1]);

    return $query->whereBetween('created_at', [
        $start->startOfDay(),
        $end->endOfDay()
    ]);
}
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #recoed #datetime #laravel
ADD COMMENT
Topic
Name
6+1 =