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

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

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

Updated on: 29-Jan-2020

218 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements