You can use the PHP substring function substras:
$year = substr($date,0,4);
$month = substr($date,4,2);
$day = substr($date,6);
If your source line as a leading or trailing space failed, then its best feed substrtruncated the input as. Therefore, before calling substr, you can do:
$date = trim($date);
source
share