Insert current date in a Confluence template (onDemand)

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

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>

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?

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.

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
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

1,040 views 2 13
Read article

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