Sign in
Log inSign up

How to put the correct year in the footer

Luciano Schillagi's photo
Luciano Schillagi
·Aug 13, 2021·

1 min read

Sometimes I see that the footer year is wrong (for instance, say 2020 where should say 2021)

In ReactJS we can solve this with something like:

import React from 'react';
import { Container, Copyright } from './footer.styles';

class Footer extends React.Component {

 constructor(props) {
  super(props);
  this.state = {currentYear: new Date().getFullYear()};
 }

 render() {
   return (
   <Container>
     <Copyright>© { this.state.currentYear } ~ My Web Site</Copyright>
   </Container>
   )
  }
}

export default Footer;

I hope this code help you!