Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Insert current date into Confluence page

Liam Nicholls December 14, 2011

Hello

Is there any wiki markup to insert the current date onto a Confluence page.

I am wanting to export a PDF from a single page (it is a report for external users not on the onDemand app) and I am wanting the date of the report to be displayed on the PDF.

thanks

15 answers

1 accepted

13 votes
Answer accepted
Liam Nicholls December 29, 2011

Thanks Bob, I've just tried this on my Confluence page, however I don't think it works. I'm using JIRA onDemand, so tha plugin may not be installed.

This feature has been requested by the way in response to my support query

https://studio.atlassian.com/browse/JST-5724

Bob Swift OSS (Bob Swift Atlassian Apps)
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.
December 29, 2011

Yes, you need to be able to install the plugins in order for them to work :). OnDemand doesn't allow that currently.

16 votes
Steven F Behnke
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.
August 28, 2014

@Karie Kelly

@tk385

Ask new questions. New questions keep the format clean. It took me a few moments to even find who posted here, because you commented on an old issue.

After a little more searching I found this. Boris Mocialov has the right answer. https://answers.atlassian.com/questions/266126/how-do-you-display-current-date-and-time-in-confluence-using-user-macro-and-how-do-you-add-it-like-a-date-and-time-stamp

So let's walk though a basic implimentation for it.

  1. You'll need to navigate to your Confluence installation via your browser
  2. Click the Gear icon and press Confluence Administration
  3. On the left side, press User Macros
  4. Press Create a New User macro
  5. Paste my below code into Template and fill out the following form fields as such:

## Macro title: Current Time
## Macro has a body: N
## Body processing: No macro body
##
## Developed by: Steven Behnke
## Date created: 28/Aug/2014
## Installed by: 

## @noparams


<p>$action.dateFormatter.formatGivenString("dd-MMM-yyyy hh:mm:ss", $content.currentDate)</p>

Once you've done that, you can add {current-time} to any page and it will print the current date and time. If you only want date you'd remove the "hh:mm:ss". If you only wanted to print on Printed PDF's you'd need to add it to the PDF Layout settings.

eyrisone April 21, 2015

This worked great for me. Any idea how to get this to work for a specific time zone? I'm working on building a clock for our different offices.

Steven F Behnke
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.
April 24, 2015

@Carlos Parada it would be easier for me to help you if you ask a new question. It's hard for me to find new comments to old questions/answers. Additionally, if you could tell me a little bit more about what you're trying to accomplish I'd be more than willing to help you.

Chris Jones November 7, 2018

Hi,

Noob question: I noticed that when I attempted this the results that I got look like this on the page. How do I lose the code that is surrounding the date?

Demo Date:  <p>07-Nov-2018 </p>

Like Evanna McMahon likes this
Tim Biddiscombe November 13, 2018

Is this only for the self-hosted version of confluence? I cannot find this on the cloud version.

Evanna McMahon April 10, 2019

Chris did you find out how to remove the code that surrounds the date ?

CJ Edwards April 15, 2020

This even at a year old still shows up in searches for confluence timestamp

remove the bits in the code part to look like this.

$action.dateFormatter.formatGivenString("dd-MMM-yyyy hh:mm:ss", $content.currentDate)

Like it likes this
2 votes
tk385 August 28, 2014

Fast forward 3 years and we are in 2014. Is there a good way to handle this now?

2 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
December 14, 2011

The reporting plugin has this capability and some other macros as well including the Run Plugin:

{run-now}
$current_time
{run-now}

Date format can be specified on the macro if needed.

1 vote
Dana Jansen - Confluence Queen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 23, 2018

insert the variable $currentDateLozenge and the system will automatically render the current date when the page is created.

Steffen Heller
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.
August 24, 2018

Can you specify:

  • Insert where: Wiki page? Template? User macro? Stylesheet? Header/Footer?
  • When WHAT page is created: Wiki page? PDF?
Dana Jansen - Confluence Queen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 1, 2018

@Steffen Heller- These variables can be entered into Confluence Templates and certain Macros that support these kinds of variables (and no I won't list them here because I don't know them all)

When we're talking about pages - we're talking about confluence pages.

Deirdre Curle August 5, 2020

Hi @Dana Jansen - Confluence Queen , thank you for your response. I have tried your suggestion in a Confluence template. When I create a page based on the template, it creates the variable, but it is blank - it doesn't populate with the current date. When I fill in the date it holds the value in the variable. I really want it to default to the current date. The user shouldn't have to do anything. Any suggestions?

Like Harold Price likes this
0 votes
Shri May 19, 2020

Insert ‘Contributors’ Macro

This helped me with what I needed, a place to see who edited the page and when.

0 votes
Steffen Heller
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.
April 27, 2015

@Karie Kelly

If you managed to create a current date somehow and you just need to know how to get it into the footer of a PDF, here is how you can do that:

On the wiki page:

Put that date inside a CSS class called "runningfooter" (could be any name, but has to be the same as in the PDF export stylesheet)

In the PDF export stylesheet:

Enter the following code

 

@page {
@bottom-right { 
content: element(runningfooter); 
}
}
.runningfooter { 
position: running(runningfooter); 
}

 

 

 

carolyn french
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 7, 2016

What would the syntax be for the CSS class that calls the user-created macro to calculate the current date please?

Lebende Legenden August 28, 2018

Kinda late for that but...

Steffen could you please give an example on how you put the date into a css class.

Got a working macro with the date in dd.MM.yyyy format.

Also added the stylesheet parts to mine but can't get it to work.

Thanks in advance.

Steffen Heller
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.
August 28, 2018

https://community.atlassian.com/t5/Confluence-questions/Insert-current-date-into-Confluence-page/qaq-p/313517#M96812 was my attempt to answer this very question.

Did you try it didn't work (which could be possible since I didn't have a macro and couldn't try it) or what information do you need?

0 votes
Steven F Behnke
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.
August 28, 2014
Yes I have an answer below. Please look at it I think it answers your problem.
0 votes
tk385 August 28, 2014

We're not on OnDemand either. I can't imagine such a such task cannot be done without going through hoops. My use case is the same - just need to put a "printed on" date on the PDF so it's clear when the document is being generated.

0 votes
Steven F Behnke
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.
August 28, 2014

I don't think you have the ability to mark my answer as correct in a thread you don't own, either. Which is lame.

0 votes
Karie Kelly
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.
August 28, 2014

Really?? There are many comments on this that obviously need it. We are not OnDemand and do need it. We need it to indicate an as of date when providing PDF documents to others (whether client or internal).

0 votes
Steven F Behnke
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.
August 28, 2014

You should really ask a new question. Please include your use case where you need the time (pdf exports? all pages? what do you really need... Are you also on OnDemand?)

0 votes
Mick Davidson
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.
May 21, 2013

Steffen,

When you export to PDF, the date and time the PDF was created is part of the name that is automatically generated. Would that be sufficient for your needs? Cheers

Steffen Heller
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.
May 21, 2013

Interesting point. But no, that is not really sufficient.

Anyways, I think I just found a possible solution. I can achieve what I want indirectly:

I put the user macro on the confluence page, build a div around it and then copy the div to the header.

Karie Kelly
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.
April 10, 2014

As an administrator who isn't a developer, I'm not too fluent in building macros. Could you provide more details for me on how you accomplished this as I am needing to have the current date on a page when it is rendered or exported or a date in the page/space PDF export footer.

I would appreciate any help you can offer!

0 votes
Steffen Heller
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.
May 21, 2013

I also want the current date. But I want it to appear in the footer of my PDF page. Just started thinking about it and got my doubts if this is possible at all. I mean, I would need to create something like this:

@page {
@bottom-center {   
content: {NAME OF MY MACRO}; 
}  
}

Is this possible? Can user macros be used in combination with "content:..."? Or how else could this be achieved?

0 votes
Matt
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 29, 2011

Liam, could you not achieve this by customizing the PDF Stylesheet with CSS? I don;t know enough about CSS to know if it is possible but thought it might be an option.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events