getCollectionDatePublic(); $dateFormat not working

Permalink 1 user found helpful
$page->getCollectionDatePublic($dateFormat = 'jS F Y', $type = 'system');

In the documentation it says you can define a $dateFormat using PHP date() format, though it's not working it still prints 2014-10-14 23:48:00

View Replies: View Best Answer
hutman replied on at Permalink Reply
The documentation that you are using is for Concrete 5.6, not 5.7 the getCollectionDatePublic function does not take any parameters in 5.7
andrewhawkes replied on at Permalink Best Answer Reply
I wonder why they took it out?

Anyway one solution is to use php strtotime, I did the following to format the date how I needed it.

    $collectionDate = strtotime($c->getCollectionDatePublic());
    $date = date("d/m/Y", $collectionDate); 
<time datetime="<?php echo $c->getCollectionDatePublic(); ?>">
    Posted: <?php echo $date; ?>
JoshRendezvous replied on at Permalink Reply
Thanks @andrewhawkes! Was looking for date formatting everywhere! This worked great for the page list block! Appreciate it! Edit: FOR 5.7 *sigh*
ibloxser replied on at Permalink Reply
The solution from andrewhawkes just gave me the same date on every item in the page list block. I have edited it a little so it works for me (Concrete

1. First I made a copy of the page_list folder in (concrete>blocks) and placed it in (application>blocks).
2. Then I open the folder (application>blocks) and make a new folder "templates"
3. In the folder templates I did make another folder with the templatename.
4. Copy the view.php and view.css into the folder with the themplatename.
5. Delete the rest of the contents so you only have the folder templates in (application>blocks>page_list)
6. Now edit the view.php in the folder (application>blocks>page_list>templates>templatename)
7. Change line 53
$date = $dh->formatDateTime($page->getCollectionDatePublic(), true);
$collectionDate = strtotime($page->getCollectionDatePublic());
$date = date("d/m/Y", $collectionDate);
8. Change line 116
<?php echo $date?>
<time datetime="<?php echo $page->getCollectionDatePublic(); ?>"><?php echo $date; ?></time>

And it works! :)
If you want to change the date format you can change d/m/Y to something else.
Look here what to use:
TeKnoZiz replied on at Permalink Reply
Awesome, that worked for me!