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

 
hutman replied on at Permalink Reply
hutman
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
andrewhawkes
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.

<?php
    $collectionDate = strtotime($c->getCollectionDatePublic());
    $date = date("d/m/Y", $collectionDate); 
?>
<time datetime="<?php echo $c->getCollectionDatePublic(); ?>">
    Posted: <?php echo $date; ?>
</time>
JoshRendezvous replied on at Permalink Reply
JoshRendezvous
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
ibloxser
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 5.7.5.3)

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);
To:
$collectionDate = strtotime($page->getCollectionDatePublic());
$date = date("d/m/Y", $collectionDate);
8. Change line 116
<?php echo $date?>
To:
<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:http://php.net/manual/en/function.date.php...
TeKnoZiz replied on at Permalink Reply
TeKnoZiz
Awesome, that worked for me!
Kurtopsy replied on at Permalink Reply
Kurtopsy
Thanks!! This even works with V8 too.