Home Forums General Issues Entering and Displaying Time Duration Reply To: Entering and Displaying Time Duration

  • Hi @awilder

    The best solution is to create a custom field type for you specific needs.
    You can read how this is possible here:

    If a faster approach is needed, I would create 2 select fields; one for hour and the other for minutes.

    The label for each value would look pretty like “2 hours”, but the value it saves would be “2”. This way, you can construct the recipe markup like so:

    $hours = get_field('hours');
    $minutes = get_field('minutes');
    $markup = 'PT';
    if( $hours )
    	$markup .= $hours . 'H'
    if( $minutes )
    	$markup .= $minutes . 'M'
    echo $markup;