Display actual publication and modified dates and times

I would like my page to show the actual publication and modified dates and times and not how many minutes, days or months ago since the publication or modified dates:
At the moment, this is showing up on my pages in Plone:

by awong — published 41 minutes ago, last modified 41 minutes ago

Is there a way I could display the actual date and time in Plone? Any advise would be most appreciated. Thanks so much.

Plone 5.0.8 (5018)
CMF 2.2.10
Zope 2.13.26
Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
PIL 3.4.2 (Pillow)

What you see is probably rendered with pat-moment (so there is a javascript changing the date)

something like:

 <span tal:content="python:view.toLocalizedTime(item['time'],long_format=True)"
                    class="pat-moment" data-pat-moment="format:relative;"/>

If you disable javascript you will see what the 'real dates are'.

So, what you probably need to do is to modify the template (or disable the javascript) and just remove or edit the 'pat-moment' class

You can find some more info here: http://plone.github.io/mockup/dev/#pattern/moment

I think this should be configurable by default; do you mind to open an issue on Plone's issue tracker?

espenmn and hvelarde, thank you so much.

I could change the template and got the result I wanted. However, I am having issues overriding the default through my theme product. My customized template is at zeocluster/src/mytheme.name/src/mytheme/name/browser/templates/plone.app.layout.viewlets.document_byline.pt

This is what I have in my zeocluster/src/mytheme.name/src/mytheme/name/browser/configure.zcml:


  <!-- Set overrides folder for Just-a-Bunch-Of-Templates product -->
  <include package="z3c.jbot" file="meta.zcml" />

  <!-- Publish static files -->


I keep getting this error:
ConfigurationError: ('Invalid value for', 'layer', "ImportError: Couldn't import mytheme.name.browser.interfaces, No module named interfaces")

Am I missing something? Any advise would be most appreciated. Thank you so much.

in the folder my theme/name/browser you need a file called interfaces.py, and in that file you need to define the 'layer',

Maybe it helps looking here:


You might also need (to put it here):

This is awesome! Thank you so much, espenmn. This is what I did:
Created an interface.py file in the /browser folder and put the following code:
from plone.theme.interfaces import IDefaultPloneLayer

class IThemeSpecific(IDefaultPloneLayer):
    """Marker interface that defines a Zope 3 browser layer.

It is now working like a charm! THANK YOU SO MUCH!!!! Cheers!!!! :slight_smile:

for the record it's also possible to do it in the theme with something like that added to rules.xml

<xsl:template match="//*[@class and contains(concat(' ', normalize-space(@class), ' '), ' pat-moment ')]/@data-pat-moment">
      <xsl:attribute name="data-pat-moment">format:LLL;</xsl:attribute>

The date format can of course be customized by replacing the 'LLL' part (see moment.js docs)

works with Barceloneta (tested on demo.plone.de), with other themes YMMV. But it could be seen as a compatibility test with Plone 5.1 if it does not work correctly the theme is not fully compaible :slight_smile:

1 Like

Oh wow! I did not know that. Thanks so much gp54321. This is great! Cheers! :slight_smile: