Anna
Anna

Reputation: 1659

How to get the current year from freemarker template

I have use the ${.now} to get the current time stamp inside the freemarker templates, but I want to know how can I get only the year?

Upvotes: 22

Views: 12757

Answers (1)

ddekany
ddekany

Reputation: 31152

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

Upvotes: 57

Related Questions