显示更新表单的日期= date

发布于 2025-02-09 11:10:37 字数 530 浏览 0 评论 0原文

当我更新注册数据时,我正在尝试显示保存在数据库中的当前日期。当我单击以更新寄存器时,所有带有input type = text的字段显示在数据库中的数据中显示,但是具有input type type> input type = date显示为MM /dd/yyyy,而不是存储的数据。是否可以在我的更新表单中显示使用input type = date存储的日期?感谢您的帮助。 这是我的输入:

        <label for="birth_date">Birth Date: </label>
        <input
          type="date"
          class="form-control"
          name="birth_date"
          id="birth_date"
          value="<%= patient.birth_date %>"
        />

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"
          class="form-control"
          name="birth_date"
          id="birth_date"
          value="<%= patient.birth_date %>"
        />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

简单爱 2025-02-16 11:10:37

确保detter.birth_date的值在yyyy-mm-dd格式中。 mdn

注意:显示的日期格式将与实际值不同 - 显示的日期是根据用户浏览器的语言来格式化的,但是解析的值始终格式化yyyy-mm -dd

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文