Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to macro today's date minus (days)

Matthew Singleton January 30, 2018

So this (as a macro) gives me today's date in a page:

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

But what I want to do is today's date - a number of days i.e. currentDate - 1d

Any ideas?

2 answers

1 accepted

2 votes
Answer accepted
Stephen Deutsch
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.
January 30, 2018

This should work (current date - 3d):

#set ( $date = $action.dateFormatter.calendar )
$date.setTime($content.currentDate)
$date.add(6, -3)
$action.dateFormatter.formatGivenString("dd-MMM-yyyy", $date.time)

as a bonus, in Confluence-styled format:

#set ( $date = $action.dateFormatter.calendar )
$date.setTime($content.currentDate)
$date.add(6, -3)
<time datetime="$action.dateFormatter.formatGivenString('yyyy-MM-dd', $date.time)"/>
0 votes
Matthew Singleton January 31, 2018

Genius.. worked perfectly. I literally would never have worked this out.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events