Input type DateTime - Value format?

RobinJ picture RobinJ · Jun 1, 2012 · Viewed 302.4k times · Source

In which format should I put the date and time, for use in the HTML5 input element with datetime type?

I have tried:

  • 1338575502
  • 01/06/2012 19:31
  • 01/06/2012 19:21:00
  • 2012-06-01
  • 2012-06-01 19:31
  • 2012-06-01 19:31:00

None of them seem to work.

Answer

Hitham S. AlQadheeb picture Hitham S. AlQadheeb · Jun 1, 2012

For <input type="datetime" value="" ...

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

Update:

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.

Why is HTML5 input type datetime removed from browsers already supporting it?

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime