How can I get last modified date of a page brought into a Page properties report
Asked by Jonathan Seal:

I'm creating a set of pages which each are using the page properties to hold a small table of data such as owner, status etc... and then using another page to hold a page properties report to provide a single view of where all the pages are up to. So far so good.

But I want to include the last modified date in the table and have that also reflected in the page properties report. I came across an article which talks to this: <https://confluence.atlassian.com/confkb/how-to-display-modified-page-dates-in-a-table-1005791769.html> but this means that every time you add the table into a new page you need to manually select the page that you want to the last modified date to apply to (when I just want it to be set to "this page"). However I don't know the syntax that would achieve that. Any ideas or better ways of doing this?


Answers:
author: Dominic Lagger
body: Hi [@Jonathan Seal](/t5/user/viewprofilepage/user-id/4021207)

The user macro is a great way to display the last modification date. You just need this macro:

```
## This is an example macro
## @noparams

#set( $containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager') )
#set( $getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null) )
#set( $containerManager=$getInstanceMethod.invoke(null,null) )
#set( $containerContext=$containerManager.containerContext )
#set( $pageManager=$containerContext.getComponent('pageManager') )
#set( $page = $pageManager.getPage($content.getId()) )

$page.getLastModificationDate()
```

This macro shows the last modification date of the actual page.

Regards, Dominic

comments: author: Jonathan Seal
body: Hi Dominic - thanks so much! I've dropped this into a new macro and it brings the correct data through and into the report. :) The only thing that would make this better would be to format the date in a more meaningful way. Currently it comes across as:

2020-07-22 10:18:17.027

I certainly don't need the milliseconds, but would also like it to be formatted

DD-MM-YYYY HH:MM

All other dates in confluence appear along the lines of the second example and I'd like to follow that for consistency.

Is that possible by changing the macro in some way?

Much appreciated!


author: Dominic Lagger
body: Hi [@Jonathan Seal](/t5/user/viewprofilepage/user-id/4021207)

Date handling in confluence user macros is quite hard...

I was not able to get it done. Please see the documentation and perhaps you will get it :)

* [ConfluenceEntityObject](https://docs.atlassian.com/ConfluenceServer/javadoc/7.2.0/com/atlassian/confluence/core/ConfluenceEntityObject.html) (getLastModificationDate())
* [Oracle Date](https://docs.oracle.com/javase/6/docs/api/index.html?java/util/Date.html)
* [Oracle Calendar](https://docs.oracle.com/javase/6/docs/api/index.html?java/util/Calendar.html)

Regards, Dominic


author: Jonathan Seal
body: Thanks. I followed the link and went down a rabbit warren but ended up finding a detail which I used to change the last line to:

```
$action.dateFormatter.formatDateTime($page.getLastModificationDate())
```

and it seems to have worked. I've also then tidied up the general settings for how dates are displayed so it's more like dd/mm/yyyy and we're good now. Thanks for the help and pointing me in the right direction!


Tags: confluence-server

macro

page-properties-report

page-property

server