Get Current Date Month Year in React js

Example 1 : Get Current Date Month Year in React js

Index.js

import React from 'react'
import ReactDOM from 'react-dom'
function CDate(){
const cdate = new Date().toLocaleDateString();
return(<h3>{cdate}</h3>)
}
ReactDOM.render(<CDate />,document.getElementById("root"));

Example 2 : Get only current date in react

Index.js

import React from 'react'
import ReactDOM from 'react-dom'
function CDate(){
const cdate = new Date().getDate();
return(<h3>{cdate}</h3>)
}
ReactDOM.render(<CDate />,document.getElementById("root"));

Example 3 : Get only current month in react

Index.js

import React from 'react'
import ReactDOM from 'react-dom'
function CMonth(){
const cmonth = new Date().getMonth();
return(<h3>{cmonth}</h3>)
}
ReactDOM.render(<CMonth />,document.getElementById("root"));

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Web-Tuts

Web-Tuts

Web Tuts is a web programming help. Here you can learn React, laravel, Codeigniter, jQuery, JavaScript, Node js, Angular js, Wordpress, etc.