Peter Knight Posted November 19, 2014 Share Posted November 19, 2014 The published field of a page is: {$update->blog_date} and outputs as 8 March 2013 12:00 am If I want to change the Date Format to March 2013, is it advisable to change this via PHP or directly via the field settings. I notice I can specify the Date/Time Output Format Code via the field the Details and Input tabs but I'd rather not mess around with the source info. I'm guessing I've to create a variable based on the published date and then use some filter to specify M, YYYY. Just looking for a point in the correct direction. Thanks. Link to comment Share on other sites More sharing options...
Joss Posted November 19, 2014 Share Posted November 19, 2014 Wellllllllllllll Kind of depends what you want to do! If you want the output of that specific field to look the same every time for consistency, then do it at the field end. if you want to change it (sometimes have only a bit, sometimes display as a shorter format), then just output it unformatted and use the php date thingy to do what you want. http://cheatsheet.processwire.com/page/built-in-methods-reference/page-getunformatted-field/ 1 Link to comment Share on other sites More sharing options...
kongondo Posted November 19, 2014 Share Posted November 19, 2014 Yep, I agree with Joss here. If you wanted to manipulate the value at runtime, here's an example based on Joss PHP date thingy... $myDate = date('F Y', $pages->get(5108)->getUnformatted('blog_date')); echo $myDate; //Outputs August 2014, for example. 2 Link to comment Share on other sites More sharing options...
Peter Knight Posted November 19, 2014 Author Share Posted November 19, 2014 I guess I'm planning on changing the output format depending on the template. Therefore, starting off with the most detailed info and whittling it down to just Month Year would be best so I'll run with something like this $customdate= date("M Y", $update->getUnformatted("blog_date")); Cheers Joss. Cheers @Kongondo. Looks like we posted at the same time again 1 Link to comment Share on other sites More sharing options...
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