I have the following date format:
201705
I would like to put a /
between the year and the month. How do I do this?
I have the following date format:
201705
I would like to put a /
between the year and the month. How do I do this?
If you're working with dates, use DateTime::createFromFormat
:
$date = DateTime::createFromFormat('Ym', '201705');
echo $date->format('Y/m');
See the example on ideone
If it's just a string
with this default, you can use substr_replace
:
echo substr_replace('201705','/', 4, 0);
See the example on ideone