Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show seconds on input type=date-local in Chrome

In google chrome if I set the value of an input of type datetime-local to a time containing seconds where the seconds value is 0 Chrome decides not to show the seconds value on the input, meaning the user can't set the seconds at all.

E.g. If I set the value to 2013-10-24T20:36:01 then Chrome will show an input and the user can change the day, month, year, hours, minutes and seconds to whatever they want (including 0). If I set the value to 2013-10-24T20:36:00 then the seconds part disappears. I can understand it not being shown if no value for seconds was passed in but I am explicitly setting them to 0 so I would have assumed it would show them.

The reason why this is a problem is because I am reading the times from a database and if any of them have been set to 0 seconds the user can't change the time without hacking it with developer tools!

Am I missing something?

Thanks!

like image 800
Tom Jenkinson Avatar asked Oct 21 '13 20:10

Tom Jenkinson


People also ask

Can I use input type datetime-local?

One thing the datetime-local input type doesn't provide is a way to set the time zone and/or locale of the date/time control. This was available in the datetime input type, but this type is now obsolete, having been removed from the spec.

How do you insert date and time in HTML?

The datetime input type is used in HTML using the <input type="datetime-local">. Using this, allow the users to select date and time. A date time picker popup is visible whenever input field is clicked. Note − The input type datetime is not supported in Firefox and Internet Explorer.


1 Answers

Adding step attribute will resolve your issue.

<input type=datetime-local value="2013-10-24T20:36:00" step="1"> 

The default value of step attribute is 60 (one minute).

like image 120
int32_t Avatar answered Sep 16 '22 21:09

int32_t