How to detect the browser's format for HTML input type date

An input.the valueAsDate method returns a Date object reflecting the input's current value. The displayed value follows the same format. To make it work:

new Date().toISOString().substr( 0, 10 );
new Date().toLocaleDateString();


new Date( input.valueAsDate );
new Date( input.valueAsDate ).toISOString().substr( 0, 10 );
Samual Sam
Samual Sam

Learning faster. Every day.