How to show activity email feed dates as "days ago", "just now" etc

cancel
Showing results for 
Search instead for 
Did you mean: 
pcharsle
Active Member II

How to show activity email feed dates as "days ago", "just now" etc

We are customizing our email template activities-email.ftl. The date of the activity is currently displayed using the following freemarker statement:

${activity.postDate?datetime?string.medium}

However, since many of our users are in different timezones we would like to display the date in a relative format, e.g "2 days ago", "3 hours ago", "1 week ago" etc.

We notice that activities displayed on the Alfresco Share activities dashlet are already displayed like this.

Does anyone know if there is an existing function that we can use to do this or do we have to create our own freemarker function in the template?

2 Replies
angelborroy
Alfresco Employee

Re: How to show activity email feed dates as "days ago", "just now" etc

You have to build it by yourself, as it's not supported by FreeMarker out-of-the-box:

Built-ins for date/time/date-time values - Apache FreeMarker Manual 

Hyland Developer Evangelist
angelborroy
Alfresco Employee

Re: How to show activity email feed dates as "days ago", "just now" etc

Alfresco is using a YUI JavaScript function to provide this feature:

https://github.com/Alfresco/share/blob/master/web-framework-commons/src/main/webapp/js/alfresco.js#L...

Hyland Developer Evangelist