How can one fetch and print the current year without using document.write()
in JavaScript?
This is for a typical copyright line in the footer; e.g., © 2017 Stack Overflow.
Right now I'm using the standard document.write()
method.
document.write(new Date().getFullYear());
document.getElementById("someElementId").innerHTML = new Date().getFullYear();
? (The date/copyright part of this is irrelevant, right? As in, you just need to be able to display any value that comes from JS?) – Nourishment[Violation] Avoid using document.write().
because it adversely affects performance. – Rufena