This question already has an answer here:
I'm trying to enter the date in tags default_items.php (in an override) to see the date in tags list.
I am using
<?php echo $item->displayDate; ?> and this prints: 2018-08-04 06:04:37, but I'm trying to format the date as 4 Aug 2018.
I tried the code below to change the format and display:
<?php $mydate = $item->displayDate; echo $mydate->format('j M Y'); ?>
but this generates an error:
Call to a member function format() on string
How can I change the date to the new format?