Mask for hour 24:00

Asked

Viewed 159 times

1

Good evening, everyone.

I would like your help for a problem. I have a field in my form to receive time. But what I have found few validate. Most do so: When you type 24:00 it turns to 00:00 ... but that’s what I want to avoid. In my field I need to put 24:00... it would be 23:59 24:00 now if I type 24:01 then yes I would have to stay 00:01... Do you have any tips on how I can do this?

  • Are you using <input type="date"> or something different? I’m not sure if it has to do with bootstrap

  • 1

    What is the reason for this, because what you do not want is the correct behavior 23:59 after 00:00?

  • Both formats are correct, but 00:00 is preferable to 24:00. I will reply based on <input type="date">, other components are certainly based on the same Rafts.

1 answer

1


According to the ISO 8601, which is an international standard for date and time representation, the two representations are correct: 24:00 and 00:00. But the W3C defines that the element <input> of the kind date shall accept the date in the format specified by RFC 3339, where there is a:

Although ISO 8601 allows the time to be "24", this profile ISO 8601 allows only values between "00" and "23" for the hour, in order to decrease confusion.

Not only does RFC 3339 discourage the "24:00" form - style manuals and military regulations in some countries also discourage use. The manual for the US Navy and the US Marine Corps formally specifies as valid values from 0001 to 2359. (Source)

Although it is possible to make a component that accepts the value 24:00, I do not see much advantage in so much work to format the date in a non-standard format.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.