I am trying to make the format showed with the html input attribute type="date" from English format to European format. I only want to display the European format to the user, but not affect the value that goes to the back-end.
Change display format of html input attribute type="date" to European format
Asked Answered
You can try to enforce it with HTML
<html lang="de"> <!-- German locale -->
or JavaScript:
const dateInput = document.getElementById('eu-date');
dateInput.addEventListener('change', function() {
const [year, month, day] = this.value.split('-');
const euFormattedDate = `${day}/${month}/${year}`;
console.log(euFormattedDate); // DD/MM/YYYY
});
but, the best practice is just to leave it as is
because the element automatically adapts its "presentation format" to the client's browser or OS locale. (depends upon the browser)
© 2022 - 2025 — McMap. All rights reserved.
dd/mm/yyyy
format. Did you mean change to using en-GB locale? Also, English is a European language! – Cresa