Insert current date in a Confluence template (onDemand)

Brad Mitchell
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 1, 2016

I am trying to add the current date to a template similar to Meeting Notes. Running OnDemand so adding a user macro is not an option as described here: https://answers.atlassian.com/questions/25481

The Meeting Notes template uses  and works great but only works on that specific blueprint. 

Is there any plugin or way of automatically inserting the current date with the Confluence Cloud version?

2 answers

1 accepted

3 votes
Answer accepted
Milo Test
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2016

I used the ‘CYO Create-Your-Own Custom Macro’ Macro to display the current date using this code:

<h1>
<script type="text/javascript">
    var d = new Date();
    var curDate = d.getDate();
    var curMonth = d.getMonth() + 1; //Months are zero based
    var curYear = d.getFullYear();
    var dateCode = ((curMonth<=9 ? '0' + curMonth : curMonth) + "" + (curDate<=9 ? '0' + curDate : curDate) + "" + curYear)
    document.write(dateCode.small());
</script>
</h1>
0 votes
Aleksander Boron
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 20, 2017

Hi

This doesn't work for me :(

After pasting this in left window it is treated literally as text and the javascript code is displayed in one line on the page.

Does anyone know why? And where are docs which explains what is the difference between left and right window?

Riccardo July 18, 2018

Milo Grika's code does work.

after replacing all the HTMLSpecialChars with normal characters.

Click administration wheel -> general configuration -> user macro's.

Add his code as rendered.

From there you can add is as a macro '{' on your pages.

 

Edit: I have to add that 'User Macros' only work on Server platform, not Cloud platform.

Casey Maynard
Contributor
July 31, 2018

I seem to have difficulty in adding this as an available macro

I have created the following setup (see below)

But when I type {testpicker

the macro does not appear

 

Macro Name: testpick

Macro Title: testpicker

Macro Body Processing: Rendered

Template: 

<h1>
<script type="text/javascript">
var d = new Date();
var curDate = d.getDate();
var curMonth = d.getMonth() + 1; //Months are zero based
var curYear = d.getFullYear();
var dateCode = ((curMonth<=9 ? '0' + curMonth : curMonth) + "" + (curDate<=9 ? '0' + curDate : curDate) + "" + curYear)
document.write(dateCode.small());
</script>
</h1>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events