skip to Main Content

PHP – get closest date from array – Laravel

I want to get closest date from $search_date if is not same values in $array['date']. If is same value in $array['date'] I want all array. Format date is 'Y-m-d'. Example 1: $search_date = '2022-12-08'; $array = [{"price":"200","date":"2022-12-12"},{"price":"50","date":"2022-12-10"},{"price":"100","date":"2022-12-10"}] Return should be:…

VIEW QUESTION

difference between two times Laravel Carbon

I want to check difference between two times in Laravel (the day is not needed) Carbon::createFromTimeString($this->debut) ->diffInHours(Carbon::createFromTimeString($this->fin)) if $this->debut = '08:00:00' and $this->fin = '02:00:00' the expected result is 18 but I have 6 How can I get the correct…

VIEW QUESTION
Back To Top
Search