Date Counter for Documents

I'm investigating to find out if it is possible to create a date counter for Confluence for when a page has been created and modified (see example below). We are on a tight budget so we can't fork out money to pay for such feature. I was wondering if it possible to achieve this with User Macro?


5 answers

1 accepted

1 vote
Accepted answer

Obviously the Archiving Plugin would be more robust, but here's a user macro that would fulfill your requirements:

## @param LimitDays:title=# of days until outdated|required=true|type=int|default=30|desc=This is the number of days until the info box will show as a warning box
#set ( $limitDays = 30)
#set ( $daysSinceCreated = ($action.dateFormatter.calendar.timeInMillis - $content.creationDate.time ) / (1000*60*60*24) )
#set ( $daysSinceLastModified = ($action.dateFormatter.calendar.timeInMillis - $content.lastModificationDate.time ) / (1000*60*60*24) )
#set ( $limitDays = $generalUtil.convertToInteger($paramLimitDays).intValue() )
#if ( $generalUtil.isInLastDays($content.lastModificationDate, $limitDays) )
  #set ( $macroType = "info" )
  #set ( $macroType = "warning")
#if ( $daysSinceCreated >= 21 )
  #set ( $sinceCreatedString = ($daysSinceCreated / 7) + " weeks" )
  #set ( $sinceCreatedString = $daysSinceCreated + " days" )
#if ( $daysSinceLastModified >= 21 )
  #set ( $sinceLastModifiedString = ($daysSinceLastModified / 7) + " weeks" )
  #set ( $sinceLastModifiedString = $daysSinceLastModified + " days" )
<ac:structured-macro ac:name="$macroType">
      <span>This page was created </span><b>$sinceCreatedString</b><span> ago. </span>
      <span>This page hasn't been updated for </span><b>$sinceLastModifiedString</b><span>. </span>

Right now the default # of days is 30, but you can change that in lines 1 and 2 if you wish (you need to change both to the same value).

This is absolutely spot on. I am really grateful of the time you have spent putting this together for me. I still have such a long way to go before I master velocity. Where did you learn all this from?

Basically a ton of trial and error and looking at the work that others have done, specifically the other prolific user macro writers:

Andrew Frayling
Matthew Horn
Steve Goldberg
Davin Studer
Sandro Herrmann
(apologies if I missed someone)

Beyond this, take a look at these pages:

Take a look at the Javadoc for the objects accessible in Velocity (and some that aren't, since it's possible to import some extra classes), including Page/ContentEntityObject.

Also, it's good to look at the documentation for version 1.6 of Velocity (the one that's included in most versions of Confluence):

For some extra ideas, I have a bunch of user macros in my Bitbucket repository:

They're getting a bit old, but you should be able to get at least a few ideas smile

I don't know about your budget, but the Archiving Plugin has this feature.


Thanks for the suggestion. I did demo this a while ago and it seems really good. I would definatly look at this in the future.

Seems possible.  What should the limit be for when a # of days is displayed as # of weeks? Above it shows 9 days ago, which is more than 1 week.  Would the cutoff be at 2 weeks or something?

I would say give it 21 days which is 3 weeks. Thanks for your time helping me with this smile

I have been trying to find a solution for a while now but everything I try doesn't seem to work.


i try to create a table macro in which two current report values can be displayed together.
"Metadata report" and "View of contributors" - see attachmend.

2018-02-02 Confluence01.jpg
Unfortunately, I do not succeed. I also have to admit that my programming experience is not very good.

The table should have 4 columns.
Page, process owner (metadata "prozessver"), date of last modify, counter "Last change before 30 days".

Can someone help me or give a tip on this?


I have tried this code, without success : (

## @param daysSinceLastModified:title=# of days until outdated|required=true|type=int|default=30|desc=This is the number of days until the page was modified

#set ( $daysSinceLastModified = ($action.dateFormatter.calendar.timeInMillis - $content.lastModificationDate.time ) / (1000*60*60*24) )
#set ( $descendantPages = $pageManager.getDescendents($content) )
#set( $prozessverantwortlicher = $metadataService.getMetadataValue(prozessver ) $!value

<th>Geändert von</th>
<th>Geändert seit < 7d?</th>
#foreach ( $page in $descendantPages )
<td><a href="${req.contextPath}$page.urlPath"> $page.title </a></td>
<td> $prozessverantwortlicher </td>
<td> $action.dateFormatter.format($page.lastModificationDate) </td>
<td> $daysSinceLastModified </td>

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Feb 06, 2019 in Confluence

Try out the new editing experience

Hi team, I’m Avinoam, a product manager on Confluence Cloud, and today I’m really excited to let the Community know that all customers can now try out the new editing experience and see some of the ...

792 views 33 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you