I am using Material-UI and this is their example code.
However I need the defaultValue to be today's current date and time; how can I go about this?
<TextField
id="datetime-local"
label="Next appointment"
type="datetime-local"
defaultValue="2017-05-24T10:30"
className={classes.textField}
InputLabelProps={{'
shrink: true,
}}
/>
I have tried to use something like this, however the issue is if month and day are 1-9 then how single digits and not double digits which means it won't set.
const currentdate = new Date();
const datenow = currentdate.getFullYear() + "-"
+ (currentdate.getMonth()+1) + "-"
+ currentdate.getDay() + "T"
+ currentdate.getHours() + ":"
+ currentdate.getMinutes();