I want to convert '01102018' in '01 -10-2018 ' I tried with date, but I have not been successful, thank you in advance.
date'('d-m-y','01102018');'
I want to convert '01102018' in '01 -10-2018 ' I tried with date, but I have not been successful, thank you in advance.
date'('d-m-y','01102018');'
Dear.
To solve your problem try the following:
//crea la variable de tipo date desde la fecha de tipo texto del ejemplo
$date = DateTime::createFromFormat('dmY', "01102018");
//formatea la fecha para imprimirla con el formato deseado
$date = $date->format('d-m-Y');
//imprime la variable
echo $date;
With that should be enough.