Php validating 24 hour time format

后端 未结 7 1611
孤城傲影
孤城傲影 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:44

    Try This

    $time="23:00:00";
    
    preg_match('#^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$#', $time);
    

提交回复
热议问题