I can get the current year in this way:

{% set currentYear = now.year %}

How do I get the next year?

{% set nextYear = now|date_modify('+1 year')|date('Y') %}
  • 1
    You're too fast, Christian.
    – Matt Stein
    Jun 13 '14 at 19:57
  • 1
    Brandon's answer is great if you're only adjusting the year (as the original question asks). But if any adjustments need to be made to the month or day, this answer would work better.
    – Lindsey D
    Jun 13 '14 at 20:28

You can also get it with:

{% set nextYear = now.year + 1 %}
  • It is really simplier! (best) But I won't unaccept first answer in order not to be rude.
    – nicael
    Jun 13 '14 at 20:20
  • No arguments there! Christian’s is a good answer too – certainly more flexible, and something that could be done with “pure Twig” (the .year property is only actually available in Craft’s extended DateTime class). Jun 13 '14 at 20:26
  • Thanks for clarification! For the future: If I am not an autor of a post, I don't get notified if you comment, so you should add @nicael.
    – nicael
    Jun 13 '14 at 20:31
  • @nicael Nice, I didn’t know SE had @ mention support. Jun 13 '14 at 20:32
  • Now I got notified. All right! =)
    – nicael
    Jun 13 '14 at 20:33

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.