html5 datetime 格式转换,关于html:输入类型DateTime – 值格式?

本文探讨了HTML5中datetime输入元素的使用问题,包括正确的日期时间格式、支持情况及跨浏览器兼容性的挑战。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我应该使用哪种格式将日期和时间用于datetime类型的html5输入元素?

我尝试过:

江户十一〔一〕号

埃多克斯1〔2〕

埃多克斯1〔3〕

江户十一〔四〕号

埃多克斯1〔5〕

埃多克斯1〔6〕

它们似乎都不起作用。

你能把你试过的代码贴出来吗?

@j08691-。

对于。

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 0

Examples:

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

我不知道怎么了,但是…imgdumper.nl/上传5/4fc8fe650df5f/…

你描述的是datetime-local型,不是datetime型。datetime实际上允许时区、偏移量等。请参见:w3c/html5:input type=datetime。

@流感,谢谢你的纠正。

对于任何希望将日期字符串转换为本文中提到的格式的人。使用javascript,您可以:new Date('valid-date-here').toISOString()

@我也面临同样的问题。能改变时间的形式吗?stackoverflow.com/questions/48880956/…

值得一提的是,随着iOS7放弃对datetime的支持,您需要使用不接受时区部分(这是有意义的)的datetime-local。

不工作(无论如何是iOS):

作品:

php for value(Windows安全):

strftime('%Y-%m-%dT%H:%M:%S', strtotime($my_datetime_input))

就我个人而言,我不在乎iOS 7:p,我在乎标准。如果苹果不这样做,那就是他们的问题。

@不幸的是,HTML5已经决定将实际存在的东西标准化,而不是将可能存在的东西标准化,而且对type="datetime"的支持已经很少了。当前的HTML5版本注意到该功能"存在风险,可能由于缺乏实现而被删除"。

另请参见stackoverflow.com/questions/21263515/…

schema.org/docs/gs.html sod apple,我将坚持彼此一致的标准。

Working with desktop chrome v53 and androud chrome.谢谢您!

本文似乎显示了可接受的有效类型

2009-11-13

13th November

starting at 8pm

8pm on my birthday

8pm on my birthday

本章介绍了在字段中使用它:

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).

不过,它似乎不起作用。imgdumper.nl/上传5/4fc8fe650df5f/…

在刚才添加的关于input元素的部分中,它给出了date和time的示例,但没有给出datetime的示例。而且,正如我在问题中提到的,简单地将它们组合起来是行不通的。

没有datetime标记@d3mon-1stvfw…不过,我没有使用date或time标签。

@d3mon-1stvfw这不是HTML5吗?

如果我有一个MySQL格式的日期时间(yyyy-mm-dd hh:mm:ss),如何使用日期时间类型?在MySQL中,我没有"t"来分隔日期和时间

这是我浪费了一个小时的时间。对于你们这些渴望成为海狸的人来说,以下的格式对我很有用:

规范对我来说有点混乱,它说要使用RFC3339,但是在我的PHP服务器上,当我使用日期格式时,它并没有初始化我的hmtl输入:(php的日期常数为"y-m-dh:i:sp",在编写时,应该去掉时区信息(我们使用的是本地日期时间,伙计们)。所以对我有用的格式是:

"Y-m-d\TH:i:s"

我本以为在datepicker显示日期时设置datepicker的值更直观,但我猜想它在不同浏览器中的显示方式不同。

这适用于设置输入值:

strftime('%Y-%m-%dT%H:%M:%S', time())

对于那些寻找这个的人来说,这个标签正确地显示为HTML5标签:

我认为日期时间只能在火狐上使用。

我用的是妈妈

moment(value).format("YYYY-MM-DDTHH:mm:ss")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值