0

i m using html5 time attribute ; like this

<input type="time" class="inputDateFromTo" id="time"  />

it is showing time in 24 hrs format ; but i want it in 12 hrs format with am/pm, ex "4.30 PM"

please suggest me the code using simple javascript or pattern attribute

1

2 Answers 2

1

You can use input type as type="datetime-local"

 <input type="datetime-local" class="inputDateFromTo" id="time">
Sign up to request clarification or add additional context in comments.

3 Comments

Didn't they removed datetime-local? Reference
i want only time not date
0

You can make one yourself using something like the following

<input type="text" required placeholder="hh:mm" pattern="\d\d?:\d\d" />
<select>
    <option selected value="am">AM</option>
    <option value="pm">PM</option>
</select>

1 Comment

yes i know this... but is there any other way using "type='time'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.