Instead of storing your values as “5 hours 13 minutes” instead store them as timestamps, e.g. 5:13
for 5h 13m
This way you can use the date/time comparator operations to answer questions
E.g. to get items under 5 hours and 30 minutes:
$args = [
...
'meta_query' => [
[
'meta_key' => 'time',
'meta_value' => date( "5:30" ),
'meta_compare' => '<',
'type' => 'TIME',
],
],
];
$query = new WP_Query( $args );
This will match a 3 hour post, or a 4:20 post, or a 5h 29min post.
You may need to add :00
for the seconds on to the end of all code and values.
For display you can use human_readable_duration
. This will include the seconds though, but the function is very simple so copying and modifying it to your requirements should be straight forward.