You could try something like the below:
<?php
$original_date = "20211019";
// Creating timestamp from given date
$timestamp = strtotime($original_date);
// Creating new date format from that timestamp
$new_date = date("d-m-Y", $timestamp);
echo $new_date; // Outputs: 19-10-2021
?>