Last active
March 3, 2024 18:17
-
-
Save esedic/4e6284a70b04a532d520415af4e0588e to your computer and use it in GitHub Desktop.
Insert current year in HTML with JavaSCript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- v1 --> | |
<p>© <script> | |
document.currentScript.insertAdjacentHTML('afterend', '<time datetime="' + new Date().toJSON() + '">' + new Intl.DateTimeFormat(document.documentElement.lang, { | |
year: 'numeric' | |
}).format() + '</time>'); | |
</script> All rights reserved.</p> | |
<!-- v2 --> | |
<p>© <script>document.write(new Date().getFullYear());</script> All rights reserved</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment