To print current year in a website with JavaScript, we call the date getFullYear method.
For instance, we write
<span id="copyright"> </span>
<script>
document
.getElementById("copyright")
.appendChild(document.createTextNode(new Date().getFullYear()));
</script>
to add a span and a script tag.
In the script tag, we call getElementById to select the span.
And then we call appendChild to append the next node that we created with createTextNode to append it as the last child of the span.
We get the 4 digit year from the current date and time with getFullYear and use that as the content of the text node.