s.alonzo
s.alonzo

Reputation: 93

JavaScript - Get and display current time in <input type="time">

How do I display the current time in an input whose type is time and hide its picker icon?

Thank you all.

Upvotes: 1

Views: 757

Answers (1)

Spectric
Spectric

Reputation: 31992

You can set the input's valueAsDate property to the current date.

You can use the ::-webkit-calendar-picker-indicator pseudo-class to select the picker icon.

input.valueAsDate = new Date()
input[type="time"]::-webkit-calendar-picker-indicator {
    background: none;
}
<input type="time" id="input">

Upvotes: 1

Related Questions