【问题标题】:Why is the value of datetime-local format changing to UTC instead of T?为什么 datetime-local 格式的值变为 UTC 而不是 T?
【发布时间】:2021-01-06 16:35:58
【问题描述】:

我正在尝试从数据库中获取datetime-local 输入类型的值,即2020-09-20 16:03:00。要在输入中显示此值,我需要格式 Y-m-dTH:m 以便值变为 2020-09-20T16:03:00 但不是那样,T 将变为 UTC 因此输入不会显示该值,因为它是格式错误。

<input type="datetime-local" value="{{ date('Y-m-dTH:m', strtotime($document->date_received)) }}">

感谢这个链接,我得到了正确的格式https://stackoverflow.com/a/49004716/7074729

【问题讨论】:

  • T 是 PHP 中时区的字符,您需要对其进行转义,即使用 \Tthis sandbox
  • @apokryfos 你是对的。谢谢

标签: php


【解决方案1】:

只需在 T Y-m-dTH:m 之前将 \ 添加到 Y-m-d\TH:m

评论区apokryfos的正确答案

【讨论】:

    猜你喜欢
    • 2015-12-14
    • 2020-12-17
    • 1970-01-01
    • 1970-01-01
    • 2011-05-12
    • 2020-11-15
    • 2015-04-29
    • 2023-03-21
    • 1970-01-01
    相关资源
    最近更新 更多