I used an API that returns a date as a string in dd/mm/yyyy format.

However, I needed that date to be in yyyy-mm-dd format.

Fortunately, such a conversion is easy to do using the DateTime::createFromFormat function in PHP:

$formatted_date = DateTime::createFromFormat('d/m/Y', $api_date)->format('Y-m-d');