I am trying to display the current date that is saved in my database when I'm updating the registered data. When I click to update the register, all the fields with input type=text
are shown with the data in the database, but the fields with input type=date
show as mm/dd/yyyy, instead of the data stored. Is it possible to show the date stored with the input type=date
in my update form? Thanks for helping.
Here is my input:
<label for="birth_date">Birth Date: </label>
<input
type="date"
name="birth_date"
id="birth_date"
value="<%= patient.birth_date %>"
/>
CodePudding user response:
Make sure the value of patient.birth_date
is in YYYY-MM-DD
format. The MDN documentation says:
Note: The displayed date format will differ from the actual value — the displayed date is formatted based on the locale of the user's browser, but the parsed value is always formatted
yyyy-mm-dd
.