Date使用PHP将字符串改为漂亮的显示格式

In a database the date is stored like this 20171127 which is todays date. Unfortunately I cannot change the way the date is stored in the database. Can I convert this string to a nice format? The excepted output is 27. November 2017.

I already looked at strtotime and strftime but there is no way to parse a string like I got.

You can do it, use date() function and combine with strtotime()

date('d F Y', strtotime($yourdatehere));

//Example
<?php echo date('d F Y',strtotime('20171112')); ?>

The result will print 12 November 2017 & 100% tested & worked on my system.

try this:

$str = "20171127";
$date = DateTime::createFromFormat('Ymd', $str);

take a look here for the specifics: datetime php manual