date object react code example
Example 1: javascript date
var d= new Date();
d.getFullYear();
d.getMonth();
d.getDate();
d.getHours();
d.getMinutes();
d.getSeconds();
d.getMilliseconds();
d.getTime();
Example 2: javascript date
const d = new Date();
d.getFullYear();
d.getMonth();
d.getDate();
d.getHours();
d.getMinutes();
d.getSeconds();
d.getMilliseconds();
d.getTime();
Example 3: 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 4: 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>
);
}