Setting format and value in input type=“date”

后端 未结 12 1585
暖寄归人
暖寄归人 2020-12-06 17:05

Is there any way to set the format of ? if no then how can i set date in this field using JavaScript in the default format of

12条回答
  •  臣服心动
    2020-12-06 17:25

    What you want to do is fetch the value from the input and assign it to a new Date instance.

    let date = document.getElementById('dateInput');
    
    let formattedDate = new Date(date.value);
    
    console.log(formattedDate);
    

提交回复
热议问题