fabjeck Posted July 9, 2017 Posted July 9, 2017 Hello Community On my website I have a newsfeed, where I want to display the datetime of when the article was published. I know there is a module called "ProcessWirePublishDate". But is it possible that it only returns the date without the time? How could I fix it. Thanks for helping
kongondo Posted July 9, 2017 Posted July 9, 2017 Welcome to the forums @fabjeck. If you are using native ProcessWire published page property: echo date('d F Y', $page->published);// e.g. 07 January 2017 I can't remember when 'published' property was added to ProcessWire, but hopefully it should work in the version you are running. 1
fabjeck Posted July 9, 2017 Author Posted July 9, 2017 thank you @kongondo for the quick answer. $page->published works for me but with that method I can't sort the pages by date.
kongondo Posted July 9, 2017 Posted July 9, 2017 15 minutes ago, fabjeck said: I can't sort the pages by date. $articles = $pages->find('template=article, sort=-published, limit=10');// latest first //$articles = $pages->find('template=article, sort=published, limit=10');// oldest first foreach ($articles as $a) { echo $a->title . ': ' . date('d F Y', $a->published) . '<br>'; } Is that what you are looking for? 1
fabjeck Posted July 9, 2017 Author Posted July 9, 2017 1 hour ago, kongondo said: $articles = $pages->find('template=article, sort=-published, limit=10');// latest first //$articles = $pages->find('template=article, sort=published, limit=10');// oldest first foreach ($articles as $a) { echo $a->title . ': ' . date('d F Y', $a->published) . '<br>'; } Is that what you are looking for? I had it like that, but missed a coma after the "sort" argument...but thanks for your help!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now