I would like to display current date on my site using Twig. The problem is {{ "now"|date("Y-m-d") }}
function which display me random month number like "2020-16-17". Every time when I rerun my Spring Boot program, the function shows different month number.
Asked
Active
Viewed 115 times
0

Seldo97
- 611
- 1
- 8
- 17
-
But I'm using Twig with Java Spring Boot :) – Seldo97 Apr 17 '20 at 15:14
-
I see now, perhaps it's better to remove the twig tag then to avoid confussion :) – DarkBee Apr 17 '20 at 15:20
-
I would post that as answer btw instead of placing it as an update – DarkBee Apr 17 '20 at 15:26
-
Ok, thanks for your comments. – Seldo97 Apr 17 '20 at 18:29
1 Answers
1
I solved my problem by change {{ "now"|date("Y-m-d") }}
to {{ "now"|date("Y-MM-d") }}
, "m" was showing minutes. Of course it is solution for Java.

Seldo97
- 611
- 1
- 8
- 17
-
Is uppercase `Y` correct then? In Java you would need either lowercase `y` or `u`. – Ole V.V. Apr 18 '20 at 07:20