Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Form Input datetime-local include seconds in the input?

Tags:

html

php

I can not for the life of me find where to add seconds to an input box for datetime-local

Right now it asks for M-D-Y H:M A/P, I want to add :S to the H:M part. The result would be: M-D-Y H:M:S A/P

I'm coding with PHP / HTML5

Any direction would be greatly appreciated.

like image 382
Andrew Avatar asked Feb 13 '14 19:02

Andrew


1 Answers

Add step="1" as one of the attributes on the input element. This defines the seconds field as being allowed to step by the specified amount when the up and down arrows are clicked and also shows the seconds field. Further definition of the datetime-local input element can be seen here. http://dev.w3.org/html5/markup/input.datetime-local.html

<input type="datetime-local" step="1" name="time">

The step attribute takes arguments of integers or floating point numbers (decimals) to display milliseconds as well. I haven't testing many permutations of this but it does work on a cursory try and it looks like the decimal places provided define how much of the milliseconds portion of the time can be adjusted. .1 translates to .100, .200, .300 etc. and .001 would translate to .001, .002, .003 etc.

<input type="datetime-local" step=".1" name="time">

Working jsFiddle version as well. http://jsfiddle.net/x2azB/

Hope this helps.

like image 71
Jason Bell Avatar answered Oct 23 '22 10:10

Jason Bell