public static function timetoDuration($time)
    {
        $duration = 'PT';

        $regexp = "/^([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]{1,6})?$/";

        if (preg_match($regexp, $time, $matches)) {
            $duration .= intval($matches[1]) . 'H' . intval($matches[2]) . 'M';
            $duration .= isset($matches[4])
                ? intval($matches[3]) . $matches[4] . 'S'
                : intval($matches[3]) . 'S';
        } else {
            $duration .= '0S';
        }

        return $duration;
    }