We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Question

Uploaded File datetime for output=""?

I've looked here:


and it give lots of options for output like mime and size, all very useful, but there's no datetime listed ... I'd like to display the date of the upload if possible so that visitors know when the lastest pdf was uploaded.

I know I could just ADD a date field for the perch user to update with when the upload the new file, but that seems more like a hack. Plus, the page displays about 10 or so PDF's and I think that's a convoluted approach to something as simple as output="datetime"

so, if I missed this or there's another way to do it, let me know. Thanks.

Blake Myers

Blake Myers 0 points

  • 2 years ago

Blake. Add <perch:showall/> to the template and see if one of the fields being output has the information your after. If so, you can use this data to create what you need.

Unfortunately I had already tried that ... only gave the options of filepath, mime, size, and filename ... no datetime ... I has hoping there was another way to do it, but I'm guessing there isn't

Drew McLellan

Drew McLellan 2638 points
Perch Support

Sorry, there's not an option for that - no one's ever asked for it before! It's possibly something we could add.

Drew, that would be wonderful ... sadly, I'm sure you've got bigger fish to fry and I shouldn't expect that feature anytime soon ... alas :)

I found a solution ... in the form of Template filters ... here's my code!

    class PerchTemplateFilter_timestamp extends PerchTemplateFilter 
        public function filterAfterProcessing($value, $valueIsMarkup = false)
            return date('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].$value));

and then, in the template, I asked for the output of path

<perch:content id="levelbook" type="file" output="path" filter="timestamp" />

came out right as rain ... you have to hard code the format Y-m-d, but it WORKED!