JavaScript
Automate your website's copyright date
September 15, 2020
As a new coder, it took me learning from an experiened professional that my website's copyright could be automatically updated for me--instead of setting a notification every New Years to update it!
The awesome thing is it is incredibly easy to implement and only takes one line of code:
<span>Copyright © Locksley Kolakowski {new Date().getFullYear()}</span>
Here are a few things to keep in mind:
- Unlike
<div>
,<span>
is an inline element, making it optimial for styling and adding JavaScript to your website. - Use
©
instead of © is important as not all editors support Unicode. (However, Unicode is very prevalent making this less necessary!) {new Date().getFullYear()}
gets only the year.