How to get current year from freemarker template

I am using $ {. now} to get the current timestamp inside freemarker templates, but I want to know how can I get only a year?

+5
source share
1 answer

Like ${.now?string('yyyy')} . (Note that this will return the string you need only if you want to print it. If you ever need a number so you can do arithmetic with it, then it is .now?string('yyyy')?number . )

+10
source

Source: https://habr.com/ru/post/1268099/


All Articles