# How to get current year in Thymeleaf

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Aug 7, 2019, updated Feb 18, 2020. Topics: Thymeleaf.
Canonical URL: https://attacomsian.com/blog/how-to-get-current-year-in-thymeleaf

> A protip to get current year in a Thymeleaf template.

The following code returns the **current year** in Thymeleaf:

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

## How to use it?

Here is an example to create a dropdown list for selecting credit card expiration year:

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

Another example to create a dropdown list for date of birth selection starting from 1970:

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