I have this code which I use into React app.
<Flatpickr options={{
enableTime: true,
dateFormat: "Y-m-d H:i",
}}
id="fromDate"
value={dateFrom.getTime() === 0 ? '' : dateFrom}
onChange={([date]) => {
setDateFrom(date);
}}
/>
How I can set the default time 1 month before the current time when the page is loaded?
From the official docs, you can see that there is an option called "defaultDate", you can set it using moment like so:
const defaultDate = moment().add(-30, 'days').toDate();
// ...
<Flatpickr
// ...
options={{
defaultDate: defaultDate,
// ...
}}
/>