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

This widget could not be displayed.

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>
This widget could not be displayed.

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
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

485 views 6 6
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