Signup/Sign In

How to create an input field for entering the time?

The time input field can be added to the webpage along with other elements. In HTML we can easily add a time field that will let the user enter time accordingly. It can be used to get input from the user to schedule any event.

HTML <input> with type="time"

The time can be added to <input> tag using type="time" within it. The value of time format can be in a 24-hour or 12-hour format which can be represented using hh: mm where "hh" denotes hour and "mm" denotes minute. For the input including seconds use hh:mm:ss. The time input interface varies from browser to browser.

Example: Add time within the input field

Here in the program to add time within the input field. The format used here is hh:mm in 12-hour format including A.M and P.M. You can enter time manually or click on the clock symbol to open the interface used for entering time.

Attributes for an input field with type="time"

  • max - This attribute is used to add the latest value of time. You cannot exceed the max time. The format used is hh:mm:ss
  • min - This attribute is used to add the earliest time. The format used is hh:mm:ss
  • step - It is used to define the intervals between the time. The step value is given in seconds.

Example: Attributes to time input field

Here in the example, we have added min time to start the project is 9:00 and the max time is 12:00.


The time input field lets the user enter a valid time for scheduling any event or any other purpose related to time. The time range can be set using max and min attributes. The input field provides a user-friendly interface to control the time.

About the author: