Hi I want to validate a string to check f it has valid time format. HH:MM
However,(due to some insane business reasons) I also want to validate 24:00 as correct.
The following works {([0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]} but does not validate 24:00.
Just change 2[0-3] to 2[0-4]:
^([0[0-9]|1[0-9]|2[0-4]):[0-5][0-9]$
Or if you only want to include 24:00:
^((([0[0-9]|1[0-9]|2[0-3]):[0-5][0-9])|(24:00))$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With