Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Current date in ftl template

Is it possible to print current date in specified format (Y-m-d H:i:s) in ftl (FreeMarker) ? I want to avoid passing date from controller to view.

like image 375
hsz Avatar asked Jul 23 '26 17:07

hsz


1 Answers

Freemarker is a templating library, there isn't a today variable, you should consider passing a new Date() Java Object to the template, and format it. Consider to create a wrapper class for this, to generate the new Date() exactly at the time it is called.

like image 197
Christopher Klewes Avatar answered Jul 26 '26 08:07

Christopher Klewes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!