<p>I believe: <code>{{ now | date_modify('-1 month') | date('t') }}</code></p>

CC BY-SA 3.0
2017-07-24T14:58:26.397Z
2017-07-24T14:58:26.397Z
Matt Wilcox
<p>I am working on a calendar, and so far I know how to get the number of days in the current month.
<code>{% set daysInMonth = time|date('t') %}</code></p>

<p>But how can I get the number of days in the previous month? </p>

<p>Thanks in advance. </p>

<templating><datetime><calendar>
How do I get the number of days in the previous month?
# How do I get the number of days in the previous month?

(Asked by: username_0 on 2017-07-24)

I am working on a calendar, and so far I know how to get the number of days in the current month.
`{% set daysInMonth = time|date('t') %}`

But how can I get the number of days in the previous month?

Thanks in advance.

**Tags:** templating, datetime, calendar

---

## 1 answers

### Answer by username_1 on 2017-07-24. Score: 2 | Accepted answer

I believe: `{{ now | date_modify('-1 month') | date('t') }}`


---

