-1

I want to explode from and to from date please help me how can do that thank u.

controller

   public function index(Request $request)
    {   
        return $request->date; // date: {from: "2023/03/01", to: "2023/03/02"}

        $from = "2023/03/01";
        $to  = "2023/03/02";
   
    }
  • 1
    exclude or explode? please correct your qustion – daremachine Mar 15 '23 at 14:25
  • Do you mean that `$request->date` is JSON, and you want to access `from` and `to`? If yes, this is a duplicate of https://stackoverflow.com/questions/29308898/how-to-extract-and-access-data-from-json-with-php. If not, please edit your question and clarify what you are trying to do. – Don't Panic Mar 15 '23 at 16:09

1 Answers1

0

You can parse dates with your specific format using createFromFormat().

$from = Carbon::createFromFormat('Y/m/d', $request->date['from']);
$to = Carbon::createFromFormat('Y/m/d', $request->date['to']);
mrhn
  • 17,961
  • 4
  • 27
  • 46