• Resolved bexhu

    (@bexhu)


    Hello,

    I’m making a pod template within a list like:

    Post title Audio duration Total duration
    {@post_title} || {@post_audio_duration} (180 i.e.) || 3:00 (H:i:s)
    {@post_title} || {@post_audio_duration} (120 i.e.) || 5:00

    I tried to convert int to h:m:s format, using {@audio_duration,gmdate(H:i:s)} without success.

    Later, I want to sum the time on each new row. I planned to make it with php but it seems php is deprecated on pods.

    Is there a way to make it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @bexhu

    Later, I want to sum the time on each new row. I planned to make it with php but it seems php is deprecated on pods.

    This is indeed more complex and cannot be done with Pods templates (PHP should never be used inside Pods templates!!).
    The best way to do this is to create your own PHP templates in your theme or plugin. You could assign those to a shortcode.

    You can use the WordPress core functions to create these layouts.
    See functions like get_post_meta and add_shortcode.

    I tried to convert int to h:m:s format, using {@audio_duration,gmdate(H:i:s)} without success.

    You’ll also need functions to convert a number to a time length.
    Something I quickly found online: https://www.hashbangcode.com/article/converting-and-decimal-time-php

    Good luck!

    Cheers, Jory

    Thread Starter bexhu

    (@bexhu)

    You can use the WordPress core functions to create these layouts.
    See functions like get_post_meta and add_shortcode.

    Thank You, Jory

    You’ll also need functions to convert a number to a time length.
    Something I quickly found online: https://www.hashbangcode.com/article/converting-and-decimal-time-php

    I’ll check

    btw, want to share how I solved

    function duration($secDuration){
        $seconds = intval($secDuration%60);
        $totalMinutes = intval($secDuration/60);
        $minutes = $totalMinutes%60;
        $hours = intval($totalMinutes/60);
        $timerFormat = "$hours:$minutes:$seconds";
        return $timerFormat;
    }

    On Pods {@duration,timerFormat}

    Cheers, Bexhu ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Int to H:i:s’ is closed to new replies.