html5 datetime-local control - how to hide seconds?

The seconds are by default not settable, on browsers that implement the control as defined in W3C HTML5 CR. The reason is that the granularity is set, in seconds, by the step attribute, which has the default value of 60. This is how it works in Chrome, Opera, and Safari.

If you actually wanted to allow seconds to be specified, you would set step=1.

On browsers that do not support this input type, the control degrades to a text input control, where any data can be entered by the user and the data is not processed in any way by the browser (specifically, not checked for being a date and time at all).

Update to address the modified question: If the element has a value attribute that does not satisfy the requirements set by other attributes (including the default value of step), then the input initially suffers from a step mismatch. HTML5 CR says: “When the element is suffering from a step mismatch, the user agent may round the element's value to the nearest local date and time for which the element would not suffer from a step mismatch.” Opera follows this, Chrome does not. The morale is: don’t do that. Do not use a value attribute with a seconds part if you don’t want seconds.

Tags:

Html

Css