How to manipulate the current date?

Using MediaWiki we can acess current date with:

{{CURRENTYEAR}}-{{CURRENTMONTH}}-{{CURRENTDAY2}}

The output being:

2017-02-02

However, how could I manipulate the current date so I can insert the previous month?

I've tried {{CURRENTYEAR-1}} but this doesn't seem to work.

Upvotes: 3

Views: 284

Answers (1)

Bergi
Bergi

Reputation: 665455

The builtin magic words don't allow for any manipulation, you can only insert the current date/time.

You'll need to install the Parser functions extension which lets you do all kind of shenigans:

{{CURRENTYEAR}}-{{padleft:{{#expr:{{CURRENTMONTH1}}-1|2}}-{{CURRENTDAY2}}
{{#time: Y-m-d | now -1 months }}

Upvotes: 3

Related Questions