react native system date code example

Example 1: react native get current time

var date = new Date().getDate(); //To get the Current Date
var month = new Date().getMonth() + 1; //To get the Current Month
var year = new Date().getFullYear(); //To get the Current Year
var hours = new Date().getHours(); //To get the Current Hours
var min = new Date().getMinutes(); //To get the Current Minutes
var sec = new Date().getSeconds(); //To get the Current Seconds

Example 2: react native system date

import React, { Component } from 'react';import { render } from 'react-dom';   class App extends Component {  constructor() {    this.state = {      currentDateTime: Date().toLocaleString()    }  }    render() {    return (      <div>        <p>          { this.state.currentDateTime }        </p>      </div>    );  }}  render(<App />, document.getElementById('root'));