Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current date in Thymeleaf

How can I print current date (and time, eventually) from Thymeleaf? I'm trying these functions: http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#dates but I can't get them work.

like image 893
Fred K Avatar asked Feb 26 '15 09:02

Fred K


1 Answers

Try with this:

${#dates.format(#dates.createNow(), 'dd MMM yyyy HH:mm')}

will be created a java.util.Date() object then formatted as you prefer.


Using the #calendars utility object

This is an alternative method:

${#calendars.format(#calendars.createNow(), 'dd MMM yyyy HH:mm')}

the result will be the same.

like image 191
Andrea Avatar answered Sep 20 '22 07:09

Andrea