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

JavascriptWeb DevelopmentFront End Scripts

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();

input.valueAsDate;
input.valueAsDate.toLocaleDateString();

new Date( input.valueAsDate );
new Date( input.valueAsDate ).toISOString().substr( 0, 10 );
raja
Published on 10-Apr-2018 10:59:57
Advertisements