I need a regular for time format HH:MM am/pm. I found something like
$time = "HH:MM am";
preg_match('/[\s0]*(\d|1[0-2]):(\d{2})\s*([AaPp][Mm])/xms', $time, $match);
$h = $match[1];
$m = $match[2];
$a = $match[3];
There are lot of regular expression for time. But what i am looking is if someone write aa:mn jk instead of number then it should give $h=aa $m=mn and $a=jk Or if someone keep them blank or partial filled like abcd then $h=abcd $m=null and $a=null.
I solved it using for loop and some if else but hope some can help me to do it using regular expression or using some PHP function.
Using Regex might be a little overkill. Use the
explode()function instead.