Displaying the Current Year in React

Last updated on August 16, 2022 Snowball Loading... Post a comment

In React, you can render the current year like this:

<div>{new Date().getFullYear()}</div>

The complete example below presents a copyright symbol along with the current year (you can see this everywhere on the internet).


The code:

// KindaCode.com
// src/App.js
function App() {
  return <div style={styles.container}>
    <h1 style={styles.copyright}>&copy;{new Date().getFullYear()} KindaCode.com</h1>

const styles = {
  container: {
    width: '100vw',
    height: '100vh',
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'center',
  copyright: {
    color: 'blue'

export default App;

Further reading:

You can also check our React topic page and Next.js topic page for the latest tutorials and examples.

Notify of
Inline Feedbacks
View all comments

You May Also Like