Jump to content

Template:Last month/doc

From Wikisource

Usage

[edit]

Gets the last month, given a year and (notionally "current") month. For example: 2021-05 → 2021-04; 2021-01 → 2020-12.

  • year the "current" year
  • month the "current" month
  • n how many months to go back (optional, default is 1). Can be 0 (current month) or negative (which will go forward in time).
  • format the strftime format to use. Optional, default is %Y-%m (i.e. YYYY-MM).

Examples

[edit]
{{Last month | year=2021 | month = 05}}
2021-04
{{Last month | year=2021 | month = 01}}
2020-12
{{Last month| year=2021 | month = 05 | n = 4}}
2021-01
{{Last month| year=2021 | month = 05 | n = 0}}
2021-05
{{Last month| year=2021 | month = 05 | n = -1}}
2021-06
{{Last month| year=2021 | month = 5 | format = %Y}}
2021
{{Last month| year=2021 | month = 5 | format = %m}}
04
{{Last month| year=2021 | month = 5 | format = %B}}
April
{{Last month| year=2021 | month = 5 | format = %B %Y}}
April 2021