Reputation: 415
In my react app, I am using Material UI datepicker. Unfortunately I am not able to set today's date as default date. here is my code:
<TextField
id="dateTimeFrom"
type="date"
variant="standard"
defaultValue={new Date()}
onChange={filterDateFrom}
label="Start Execution *" color="primary"
InputLabelProps={{
shrink: true
}}
/>
Can you point me to the right solution?
Upvotes: 1
Views: 9989
Reputation: 441
Try this:
<TextField
id="dateTimeFrom"
type="date"
variant="standard"
defaultValue={new Date().getDay()+"-"+(new Date().getMonth()+1)+"-"+new Date().getFullYear()}
onChange={filterDateFrom}
label="Start Execution *" color="primary"
InputLabelProps={{
shrink: true
}}
/>
Upvotes: 1