var foo = '1:00 pm'
var bar = to24Hour(foo); //bar would be 1300
function to24Hour(time) {
time.match('(\d+):(\d+) ([ap]m)');
if ($1 > 12 && $3 = pm) {
$1 = 12 + $1;
}
return $1.$2;
}
I'm trying to convert 12 hour times to 24 hours "military" time (i.e. no colon). I'm having trouble with regex capture groups and javascript but above is what I think should work.
Can someone show me the correct way?