What is the best way to add a dynamic date (year) in a Play Framework view. I want to add a copyright at the bottom of the page, but I do not want to hard code 2011
.
<p> © 2011 </p>
How can I get 2011 to always be the current year?
For Play 1.x try this
${new Date().format("yyyy")}
For Play 2.x users, the synyax is subtly different
@(new Date().format("yyyy"))
It creates the current date, and formats it (using the Format JavaExtension for the Date object).
Don't forget to add
@import java.util.Date
in template file for @(new Date().format("yyyy"))
to work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With