RyanFitzgerald / devportfolio

A lightweight, customizable single-page personal portfolio website template built with JavaScript and Sass

Home Page:https://ryanfitzgerald.github.io/devportfolio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamically change footer copyright year

vikasganiga05 opened this issue Β· comments

Change the footer copyright static year to dynamic using JavaScript Date() Object.

Screenshot

image

Solution

Change the static year to the following dynamically created year.

const currentYear = new Date().getFullYear();    // 2021

Can you give more advice on how to use this piece of code and where to put it?

Can you give more advice on how to use this piece of code and where to put it?

Yeah sure, follow these steps.

Step 1 : On index.html surround the year(2020) text in line:240 with a span tag and Add current-year id attribute to it.

- Copyright © 2020 YOUR NAME
+ Copyright &copy; <span id="current-year">2020</span> YOUR NAME

Step 2 : Add the bellow code inside js/scripts.js

// Show current year
$('#current-year').text(new Date().getFullYear());

Done πŸ‘ If you have any queries let me know πŸ™‚

Thanks for the response @vikasganiga05 ! Feel free to PR this and I'd be happy to merge it.

Thanks for the response @vikasganiga05 ! Feel free to PR this and I'd be happy to merge it.

Sorry for the late reply. I like to work on this issue πŸ™‚

I created a PR for this issue. Please review it πŸ™‚ πŸ‘

Thanks for getting that PR up, merged!