Advertisement
Virajsinh

12hr Time With AM/PM Validation in PhP

Jan 31st, 2023
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.11 KB | Source Code | 0 0
  1. $str = "01:10 PM";
  2. $pattern = "/((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))/i";
  3. echo preg_match($pattern, $str);
Tags: php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement