Php validating 24 hour time format

后端 未结 7 1593
孤城傲影
孤城傲影 2020-12-30 10:16

I\'m allowing users to pick an hour from 00:00:00 to 23:00:00 and need to check if they submit the right format. Is there a regular expression or p

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 10:27

    This matches 24 hour time including seconds

    ([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]
    

    If you only want 00 for minutes and seconds, then

    ([01]?[0-9]|2[0-3]):00:00
    

提交回复
热议问题