I have a system, which apprehends the duration of the videos in seconds, I solved by dividing by 60

$totaldur=round($totaldur/60).'min';
update_post_meta($post_id, 'duration', $totaldur);

But before I do this, the times posted were in seconds, and those are still being displayed in seconds, I’d like to make my theme show this in minutes, but I want the site every time I try because I do not know how to do it:

I tried things like this:

      <span class="duration"><?php $duration = tube_getcustomfield('duration',get_the_ID()); if(empty($duration)) $duration = ' '; 
if(is_int($duration) && $value > 0 && $value == round($duration, 0))
                {
                             echo round($duration/60).'min';
                }else{
                          echo $duration;
                                        } ?>
<!-- echo $duration; ?> -->

I have to put this condition, because in my custom field, I already have hundreds of posts with this value already divided by 60 as I showed in the first code, but many posts, 50% of them, the duration is total second, I only I want to digest when I find only numbers in the list, but it’s not working!

Read more here: How to transform the duration time output from seconds to minutes only if only numbers


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: