Get unique values from a column in a CSV and convert to JSON [closed]

Hopefully, someone here can help with this issue as I am a bit of a amateur with certain bits of PHP

I have a CSV file on a server that has dates in the second column but they are in slightly differing formats and I need to get all of the unique dates and have them as a JSON output in the format below. This needs to be a PHP-based solution. I have tried using json_encode but i can’t seem to get this to work as the date formats are different and I am unsure how to get all unique dates and also how to then reformat them before including them in a JSON file.

I have tried using file_get_contents to get the file which seems to work fine. I am then stuck on how to iterate through column b and convert the dates. When i run an ajax request to get the json file i do not get any response.

{
"result": [
    "2023-10-30T00:00:00",
    "2023-10-27T00:00:00",
    "2023-10-26T00:00:00",
    "2023-10-25T00:00:00",
    "2023-10-24T00:00:00",
    "2023-10-23T00:00:00",
    "2023-10-20T00:00:00",
    "2023-10-19T00:00:00",
    "2023-10-18T00:00:00",
    "2023-10-17T00:00:00",
    "2023-10-16T00:00:00",
    "2023-10-13T00:00:00"
]

}

Here is an example of the CSV data:

ID,TradeDate,Value
1,5/31/2023 12:00:00 AM,10
2,5/31/2023 12:00:00 AM,12
3,5/31/2023 12:00:00 AM,12
4,5/31/2023 12:00:00 AM,14
5,06/01/2023 00:00,13
6,06/01/2023 00:00,15
7,06/01/2023 00:00,14
8,06/01/2023 00:00,17
9,06/01/2023 00:00,19
10,06/01/2023 00:00,18
11,06/01/2023 00:00,20
12,06/01/2023 00:00,19
13,06/01/2023 00:00,21
14,06/02/2023 00:00,20
15,06/02/2023 00:00,22
16,06/02/2023 00:00,25
17,06/02/2023 00:00,24
18,06/05/2023 00:00,31
19,06/05/2023 00:00,43

Let me know if more information is required