Date() class in react code example
Example 1: date in react js
import React, { useState } from 'react';
import DatePicker from 'react-date-picker';
function MyApp() {
const [value, onChange] = useState(new Date());
return (
<div>
<DatePicker
onChange={onChange}
value={value}
/>
</div>
);
}
Example 2: date time react component
import React, { useState } from 'react';
import DateTimePicker from 'react-datetime-picker';
function MyApp() {
const [value, onChange] = useState(new Date());
return (
<div>
<DateTimePicker
onChange={onChange}
value={value}
/>
</div>
);
}