0

How to fix format of date in json encode. I want the format of m/d/y

    $schedule = Schedule::where('doctor_id', '10')->pluck('day', 'id')->toArray();
    //output of dates in schedule model are 11/21/2022,11/22/2022
    $data2[] = [
        'user_id' => 'My name',
        'dates' => $schedule
    ];

    return view('admin.appointment.create', compact('data2'));

this is the output I get when passing it to JavaScript

var datas = @json($data2);

//output
[{"user_id":"My name","dates":{"7":"11\/21\/2022","10":"11\/22\/2022"}}]

0 Answers0