Captioning\Cue::ms2tc PHP Method

ms2tc() public static method

public static ms2tc ( integer $ms, string $_separator = '.', $isHoursPaddingEnabled = true ) : string
$ms integer
$_separator string
return string
    public static function ms2tc($ms, $_separator = '.', $isHoursPaddingEnabled = true)
    {
        $tc_ms = round(($ms / 1000 - intval($ms / 1000)) * 1000);
        $x = $ms / 1000;
        $tc_s = intval($x % 60);
        $x /= 60;
        $tc_m = intval($x % 60);
        $x /= 60;
        $tc_h = intval($x % 24);
        if ($isHoursPaddingEnabled) {
            $timecode = str_pad($tc_h, 2, '0', STR_PAD_LEFT) . ':';
        } else {
            $timecode = $tc_h . ':';
        }
        $timecode .= str_pad($tc_m, 2, '0', STR_PAD_LEFT) . ':' . str_pad($tc_s, 2, '0', STR_PAD_LEFT) . $_separator . static::getLastTimeCodePart($tc_ms);
        return $timecode;
    }

Usage Example

Example #1
0
 /**
  * @param int $ms
  * @param string $_separator
  * @return string
  */
 public static function ms2tc($ms, $_separator = ',')
 {
     return parent::ms2tc($ms, $_separator);
 }
All Usage Examples Of Captioning\Cue::ms2tc