FreeMarker Current Date Comparison

2019-04-06 08:32发布

Is it possible to do date comparisons against the current date in a freemarker template without passing the current date into the template?

标签: freemarker
2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-04-06 08:38

From FreeMarker 2.3.17 on you can use the new special variable .now:

[#assign foo = .now > yesterday?datetime]
查看更多
疯言疯语
3楼-- · 2019-04-06 09:01

NO

Freemarker is a templating library, there isn't a today variable.

But you can pass a new Date() Java Object to the template.

查看更多
登录 后发表回答