Get Current time and date in React

  653 views   5 months ago React

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.

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]