JavaScript: Show the current year (4 digits)

Use Javascript to show the current year in a HTML-document to display the date.
Remember that Javascript is using the clients time-settings.


JavaScript Code:

<script>document.write(new Date().getFullYear());</script>

Output: 2019

And that’s everything needed to make this magic happen.

Published by


I'm a guy, born and raised in Scandinavia, around 40 years old and have worked self-employed as a webmaster in lots of different fields, niches, doing all kind of work online.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.