Reputation: 1971
I have a university-managed wiki with the basic templated from MediaWiki, but I have been adding more copying them from the Wikipedia templates.
We use it as a lab book so there is a page per day, e.g. 2018/02/02
.
I want to write a link to the previous day, i.e. yesterday, 2018/02/01
.
I tried:
{{CURRENTYEAR}}/{{CURRENTMONTH}}/{{#expr:{{CURRENTDAY}}-1}}
,
but this returns 2018/02/1
.
How do I make the day have the 0
before the single digit? As in I want 2018/02/01
and not 2018/02/1
.
My method would only work for days within the same month. Is there a wikipedia template for yesterday? How would I write it for the generic date? With a bunch of If
statements to check if the month has changed?
Upvotes: 1
Views: 117
Reputation: 4512
You can use the #time parser function to do some date calculations (anything that's supported by the strtotime() PHP function), for example:
[[{{#time:Y/m/d|now - 1 day}}]]
Or for the day before a particular day:
[[{{#time:Y/m/d|1 April 2017 - 1 day}}]]
Upvotes: 3