Input type DateTime - Value format?
我应该使用哪种格式将日期和时间用于
我尝试过:
- 江户十一〔一〕号
- 埃多克斯1〔2〕
- 埃多克斯1〔3〕
- 江户十一〔四〕号
- 埃多克斯1〔5〕
- 埃多克斯1〔6〕
它们似乎都不起作用。
对于
A string representing a global date and time.
Value: A valid date-time
as defined in [RFC 3339], with these additional qualifications:?the literal letters T and Z in the date/time syntax must always be uppercase
?the date-fullyear production is instead defined as four or
more digits representing a number greater than 0Examples:
1990-12-31T23:59:60Z
1996-12-19T16:39:57-08:00
号
http://www.w3.org/tr/html markup/input.datetime.html input.datetime.attrs.value
更新:
This feature is obsolete. Although it may still work in some browsers,
its use is discouraged since it could be removed at any time. Try to
avoid using it.The HTML was a control for entering a date and
time (hour, minute, second, and fraction of a second) as well as a
timezone. This feature has been removed from WHATWG HTML, and is no
longer supported in browsers.Instead, browsers are implementing (and developers are encouraged to
use) the datetime-local input type.
号
为什么html5输入类型datetime已从支持它的浏览器中删除?
https://developer.mozilla.org/en-us/docs/web/html/element/input/datetime
值得一提的是,随着iOS7放弃对
不工作(无论如何是iOS):
1 | <input type="datetime-local" value="2000-01-01T00:00:00+05:00" /> |
作品:
1 | <input type="datetime-local" value="2000-01-01T00:00:00" /> |
。
php for value(Windows安全):
1 | strftime('%Y-%m-%dT%H:%M:%S', strtotime($my_datetime_input)) |
本文似乎显示了可接受的有效类型
1 2 3 4 5 6 7 8 9 10 | <time>2009-11-13</time> <!-- without @datetime content must be a valid date, time, or precise datetime --> <time datetime="2009-11-13">13th November</time> <!-- when using @datetime the content can be anything relevant --> <time datetime="20:00">starting at 8pm</time> <!-- time example --> <time datetime="2009-11-13T20:00+00:00">8pm on my birthday</time> <!-- datetime with time-zone example --> <time datetime="2009-11-13T20:00Z">8pm on my birthday</time> <!-- datetime with time-zone"Z" --> |
本章介绍了在
This
example of the HTML5 input type"date" combine with the attributes min
and max shows how we can restrict the dates a user can input. The
attributes min and max are not dependent on each other and can be used
independently.
The HTML5 input type
"time" allows users to choose a corresponding time that is displayed
in a 24hour format. If we did not include the default value of"12:00"
the time would set itself to the time of the users local machine.
The HTML5 Input type week will display
the numerical version of the week denoted by a"W" along with the
corresponding year.
The HTML5 input type month does
exactly what you might expect it to do. It displays the month. To be
precise it displays the numerical version of the month along with the
year.
The HTML5 input type Datetime
displays the UTC date and time code. User can change the the time
steps forward or backward in one minute increments. If you wish to
display the local date and time of the user you will need to use the
next example datetime-local
Because
datetime steps through one minute at a time, you may want to change
the default increment by using the attribute"step". In the following
example we will have it increment by two hours by setting the
attribute step to 7200 (60seconds X 60 minutes X 2).
号
这是我浪费了一个小时的时间。对于你们这些渴望成为海狸的人来说,以下的格式对我很有用:
1 | <input type="datetime-local" name="to" id="to" value="2014-12-08T15:43:00"> |
。
规范对我来说有点混乱,它说要使用RFC3339,但是在我的PHP服务器上,当我使用日期格式时,它并没有初始化我的hmtl输入:(php的日期常数为"y-m-d h:i:sp",在编写时,应该去掉时区信息(我们使用的是本地日期时间,伙计们)。所以对我有用的格式是:
1 | "Y-m-d\TH:i:s" |
。
我本以为在datepicker显示日期时设置datepicker的值更直观,但我猜想它在不同浏览器中的显示方式不同。
这适用于设置输入值:
1 | strftime('%Y-%m-%dT%H:%M:%S', time()) |
对于那些寻找这个的人来说,这个标签正确地显示为HTML5标签:
1 | <input type="datetime" name="somedatafield" value="2011-12-21T11:33:23Z" /> |
号
我用的是妈妈
1 | moment(value).format("YYYY-MM-DDTHH:mm:ss") |
。