Dynamic Copyright Year

</ head>

</ body>

<!-- Dynamic Copyright Year -->
<script>
// get current year
const year = new Date().getFullYear();
// set .year's text to current year
// '.' + 'year' is targeting any text element with the class of 'year' 
// Use '#' instead of '.' if you wish to target a single elemnt with an ID
$('.year').text(year);
</script>

HTML/Embed

Only tabs with a " " have code.
<!-- Dynamic Copyright Year -->
<script>
// get current year
const year = new Date().getFullYear();
// set .year's text to current year
// '.' + 'year' is targeting any text element with the class of 'year' 
// Use '#' instead of '.' if you wish to target a single elemnt with an ID
$('.year').text(year);
</script>
Only tabs with a " " have code.
Only tabs with a " " have code.
Author
Noah Raskin
Published
Jan 19, 2022

How to use:

This code crumb is super simple to use. This snippet can be pasted in the </ body> section of the custom code area either in your page settings or in your sites global settings like we do on this site since we are using a symbol site wide for the footer. Meaning we have it pasted once in our sites custom code section so it gets used on every page.

Once we have that done we can go to our footer or where ever you want to display the current year in the designer and wrap the year in <span> tags. You can do this by highlighting the text/year and selecting the brush icon in the tool tip as shown below:

Now you can select that span tag and give it any class name or id you want (".year" class for our example), but make sure it matches the selector in the code above. See the code comments which will explain what to change if you're using a class or an id.

Last note: Remember that classes are used to target multiple elements while ID's are used to target a single unique element on a given page. So, use a class if you plan to have the year displayed in 2 or more spots on a single page, or an ID if you only plan to show the year in one place, like the footer for example.

It's as simple as that. Publish your site and have a look at your copyright year. It will always be current 😉

Tutorial Coming Soon!

Check Browser Support

Interactive Table

This short Javascript code crumb will allow you to dynamically set the current year for your © copyright year in your footer automatically.

Clone Project
Documentation
Author:
Built by
Built with
For the best experience

Please switch to desktop to view the content.

Back Home
Thank you! Your submission has been received!
Close Form
Oops! Something went wrong while submitting the form.
Become a Contributor