Search

Get Current time and date in React

post-title

In this tutorial, we will discuss how to get current date time in reactjs. you'll learn how to get current date and time in react js. you can optically discern current date and time in react js.

I expounded simply step by step get current date in react js. Let's get commenced with reactjs get current datetime.Type a message

Example : Get current Time

import React from 'react';
import logo from './logo.svg';
import './App.css';

class App extends React.Component {
  state={
    curTime : new Date().toLocaleString(),
  }
  render(){
    return (
      <div className="App">
        <p>Current Time : {this.state.curTime}</p>
      </div>
    );
  }
}

export default App;

Output :

Current Time : 27/12/2021, 13:35:35

i hope you like this article.