We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27716
    • 126 Posts
    Hi Guys,

    I have a template variable with a videos duration in minutes (ie 2:20)

    I want to take that figure and

    Multiply the first figure by 60

    Then and the second figure to it.

    I.e(2:20) 2 x 60 + 20

    Then store this in a TV

    Is there any built in functionality in revo that allows you to do small calculations?

    Any snippets out there?

    Any guidance appreciated.
      • 33968
      • 863 Posts
      Output modifiers are your best friend smiley

      There are built in ones that deal with dates and math, but in this case it’s best to use a simple custom modifier.

      Create a new snippet called ’hrtomin’ or something like that:
      <?php
      if (strstr($input, ':')) {
      	$timeArray = split(':', $input);
      	$hour = $timeArray[0] * 60;
      	$min = $timeArray[1];
      	$total = $hour + $min;
      }
      else $total = $input * 60;
      
      return $total;
      


      Then call it like:
      [[*tvname:hrtomin]]
        • 27716
        • 126 Posts
        Thanks So much Lucas,

        This worked perfectly.

        I used it to convert a video time to seconds for a video XML sitemap

        Thanks again,

        Stuart