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.


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.