Thymeleaf: get the current year

The following code returns the current year on Thymeleaf:

${#dates.year(#dates.createNow())}

Example usage

Create a list of options from 1900 up to the current year:

<select >
  <option th:each="year : ${#numbers.sequence(1900, #dates.year(#dates.createNow()))}"
      th:value="${year}" th:text="${year}">
  </option>
</select>

Categories

Category BootstrapCategory CoffeescriptCategory DrupalCategory GravCategory HTMLCategory JavascriptCategory JoomlaCategory jQueryCategory LaravelCategory MagentoCategory PHPCategory SharePointCategory SpringCategory ThymeleafCategory WordPressCategory Workflow

Comments

Developed and designed by Netgloo
© 2016 Netgloo