How to add current date field in a confluence template
Asked by J?rg Bofinger:

Hi all,

I'm currently working on a knowledge template in a confluence space.

I'm looking for a solution to have a filed which is filled whith the current date when the template us used by a user.

How can a do this..

Cheers J?rg


Answers:
author: Thomas Schlegel
body: Hi J?rg,

I would create a user macro "creationdate" (since this is what you want, I think):

```
## Macro title: creationdate
## Macro has a body: N
##
## Developed by: Thomas Schlegel

## @noparams

$action.dateFormatter.formatDateTime($content.getCreationDate())
```

Then, add the new macro "creationdate" to your template.

The creation date of the page is the same as the usage date of the template.

comments: author: Brendan Byers
body: Hello,  

This solution works however it renders the date as a simple string.  
Is there any way to create a macro that creates a date as a Date Picker Object:

![DatePickerObject.png](https://community.atlassian.com/t5/image/serverpage/image-id/27153i4982A01CA3537FD3/image-size/large?v=v2&px=999 "DatePickerObject.png")

We would like to add dates automatically to Tasks within a Template and the string based date doesn't add as much value as the date picker which displays as a due date in the Tasks screen.

Thank you,  
Brendan


author: Bill Bailey
body: Hey Brendan,

I was playing around with the data picker format for another macro. Here is some sample code to retrieve the last modified date and format in the data picker format.

```
#set($dateInfo=$action.dateFormatter.formatGivenString("yyyy-MM-dd", $content.getLastModificationDate()))
<div class="content-wrapper"><p>
<time datetime="$dateInfo"/>
</p> </div>
```

Hope this helps you (or anyone else who stumbles across this.


author: Edward Brett
body: Hi, this works really well, however I was wondering if it's possible to make the date picker editable after it has been added to the Confluence page via the macro, so that the date can be changed. Additionally, is it possible to get last modification date + 1 day or + 2 days?

<br />

Thanks,

<br />

Ed


author: J?rg Bofinger
body: Good Morning Thomas,

I tried out your macro and it works well so far but...only in a native page template like "plain page"

Whe I try to place it in a template like "knowledge article" it didn't work !?!

I've no clou what te reason can be...

Please help..

-------------------

Please forget what I've wrote - it all works well... Thank you for your support!

Cheers J?rg

comments: author: Thomas Schlegel
body: You're welcome, great you've made it :-)

If you think, your question is answered, please mark it as answered. With such a marker, other user may find answered questions more easy.

Viele Gr??e aus Hamburg


author: J?rg Bofinger
body: Thank you Thomas for your answer.

Just for me as a Confluence rookie... how do I add the user macro to the template?

Thanks again..

comments: author: Thomas Schlegel
body: You create a user macro in your admin section.

The user macro is added the same way as a regular macro. You find it in your list of macros after you've created it.

I've written an article about creating user macros, maybe it helps you:

<https://community.atlassian.com/t5/Confluence-articles/The-Admin-s-tale-User-Macro-filtering-a-Confluence-table/ba-p/459369>

But if not, don't hesitate to ask again :-)


author: Terri Isidro
body: Hello, I am an admin but I under General Preferences I don't see anything listed re: User Macros.  

Lower down in preferences there is a section that says "Macro Usage" but when I click it nothing appears in the right panel (basically nothing happens).  

![Capture.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/297189iB26B147FA8F86C2D/image-dimensions/167x137?v=v2 "Capture.JPG")  

If I was made an admin, shouldn't I be able to view and update macros as described here?  

Specifically I'm trying to include a macro that can be inserted to show when a page was last updated in our knowledge base article template I created.  

I found this code in another community post and was hoping to test it but can't access the area where to update macros at all:  

## @noparams  
#set ( $dateInfo=$content.lastModificationDate)  
Last Modified: $dateInfo  

<br />