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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,639,775
Community Members
 
Community Events
196
Community Groups

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.

I am thinking of creating a user macro. I've been searching and I've seen in the codes quite a lot

$action.dateFormatter.getCalendar()

I've tried to output that and it seems to get the current date and time. Question is how do i display it in a an acceptable format like "MMM DD YYYY HH:mm:ss"

Also, i think this works but more like a clock. - $content.currentDate

Is there a way for me to make it function like a date and time stamp?

5 answers

1 accepted

2 votes
Answer accepted
Matthew J. Horn
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.
Feb 24, 2014

A simpler approach might just be to use the commenting system.

Steve Goldberg
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.
Feb 24, 2014

I like this approach. Update the page, put in a note that says "I put in this macro" in the diff message.

Yes. The commenting may work like a time stamp however this will be displayed in Comment Threads within the page along with the other comments. What we want to do is to place the time stamp in a table which will display the review summary.

Steve Goldberg
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.
Feb 24, 2014

I think what Matthew was suggesting is that you users put the message in the "What did you change?" box next to the save button. These message are stored in the page history in a neat little table.

i see. Thanks! We'll do that for now

1. Define user macro (ex. macro name: "current-datetime"):

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

2. Add it to some page like: {current-datetime}

{current-datetime}

Like # people like this

1. Define user macro (ex. macro name: "current-datetime"):

2. Add it to some page like: {current-datetime}

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

1 vote
Steve Goldberg
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.
Feb 24, 2014

Would it not be simpler to just create a user macro that prints the last modfication date of the page?

That is by using the metadata correct? It is also ok to print that. But what my user wants is something that does not update everytime the page is updated.

This is so that you can just placed it after reviewed by >Insert User< last >Date Stamp Macro<

and then the next user can add another one.

reviewed by >Insert User< last >Date Stamp Macro<

such that the macros display the last time they review it or updated the document and not just the latest data.

Steve Goldberg
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.
Feb 24, 2014

Sadly this solution would mean it updates every time the page is updated.

Yes. It would be like the clock i made earlier. :(

0 votes
Matthew J. Horn
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.
Feb 24, 2014

You can use the dateFormatter's formatGivenString() method to specify a format:

$action.dateFormatter.formatGivenString("dd-MMM-yyyy", $some_date)

There are also other methods you can use. Here's the API docs on it:

https://docs.atlassian.com/atlassian-confluence/latest/com/atlassian/confluence/core/DateFormatter.html

hth,

matt

Actually, I'm already fine with $content.currentDate. It gives a complete Date and Time output. The thing is, everytime I refresh the page, so does its value.

What i need is a Date Stamp. Such that once I add it up, it becomes a static content on the page.

Is it possible with User Macros?

@Armon Tiongco1 did you manage to find an answer to your question ? (What i need is a Date Stamp. Such that once I add it up, it becomes a static content on the page.)

Elena Ovdienko _Stiltsoft_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
Oct 25, 2021

@marco.molteni Just in case you're still interested in an instrument to record the date and time on your Confluence pages, you can easily do it with our Handy Timestamp. It's one of many other macros in Handy Macros for Confluence.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events