lundi 29 avril 2019

How To format date in laravel 5.8 From "Thu Apr 11 2019 00:00:00 GMT+0200" to Mysql format?

I'm working on the backend for an App for school and I got a problem converting a date that I get from a request like " Thu Apr 11 2019 00:00:00 GMT+0200" to MySql format (timestamp)


public function getAll(Request $request){
        $start = $request->input('start');
        $end = $request->input('end');

        // we receive some thing like:
        // Thu Apr 11 2019 00:00:00 GMT+0200 (Central European Summer Time)
        $sales = Sale::with('SaleLine.lens','SaleLine.cadre','cli_sale')
                    ->whereBetween('created_a', [$start, $end])
                    ->orderBy('id', 'desc')->get();

        for ($i=0; $i < count($sales); $i++) {
            $sales[$i]['client_name'] = $sales[$i]['cli_sale']['first_name'] . " " . $sales[$i]['cli_sale']['last_name'];
        }
        return response()->success(['sales'=>$sales]);
    }



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2PB7LMr
via IFTTT

Aucun commentaire:

Enregistrer un commentaire