echo out the date of page was created

Permalink
Hello. So im working with the page list in concrete5 and i need to echo out the date of when i add the page. i try to put in this code, which works, but this only display the time current, so next time i log in the time stamp has changed.

<?php $date = Loader::helper("date"); echo $date->getLocalDateTime('now',$mask = 'd - M / Y') ?>


then i try put in this code instead, but then i get an error and im not sure what im missing :-/ Any help is appreciated.

<?php echo $c->getCollectionDateAdded('F j, Y') ?>


i get this error:

Fatal error: Call to a member function getCollectionDateAdded() on a non-object in /var.....line57

 
hhamilton replied on at Permalink Reply
would this help?

$c = Page::getCurrentPage();

thats the first thing i would try. the error indicates that $c isn't initialized anywhere (or at least not to an object). So i would look for where you are doing that, or where it should be done and make sure it happens
berteldk replied on at Permalink Best Answer Reply
<?php $c = Page::getCurrentPage(); echo $c->getCollectionDateAdded('F j, Y') ?>


This code makes it get the date from the HOME page - i need it to echo out the dates from when i created the subpages to the home page. Like this is my sitemap:

HOME
- websites
-- page to website (i need date from this page)

- design
-- page to design (i need date from this page)

Any idea on what i should type instead ?

thx
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
Something like this:
$date = $c->getCollectionDatePublic('F j, Y');
echo $date;
berteldk replied on at Permalink Reply
that give me this error:

Fatal error: Call to a member function getCollectionDatePublic() on a non-object in /var... on line 57
oaknshield replied on at Permalink Reply
oaknshield
did you ever get through with this - im tryin to do the same
gtrhough replied on at Permalink Reply
gtrhough
Are you modifying or creating your own Page List template? If so, in the original view.php in the core page list files, you will see that there is a 'foreach' statement collecting the data for each page to be displayed.

So, you could add to that...
$datePublic = date('F j, Y', strtotime($page->getCollectionDatePublic()));


Then in the html part of the 'foreach' where it echo's the url, target, title and description, you could have it echo the $datePublic.

That should give you the date each page in the page list was created.
oaknshield replied on at Permalink Reply
oaknshield
wow thanks for quick repsonse

It works - I now have dates in my page list thanks
Shine4897 replied on at Permalink Reply
I was getting the same error message and your suggestion got rid of the error message, but the date still isn't showing up. If you are still monitoring this post, would you mind helping me out?
I tried the code exactly as you posted above, and then
[$date = date(DATE_APP_GENERIC_MDY_FULL, strtotime($page->getCollectionDatePublic()))].

It seems the original error was from
[$dh->date].
Should this be referenced somewhere else that I don't know about?
madesimplemedia replied on at Permalink Reply
madesimplemedia
Hi
Just need to add echo to this to make it print out the date:

<?php $datePublic = date('F j, Y', strtotime($page->getCollectionDatePublic())); echo $datePublic ?>