<?php
    function timeToSeconds(string $time): int {
        $arr = explode(':', $time);
        if (count($arr) == 3) {
            return $arr[0] * 3600 + $arr[1] * 60 + $arr[2];
        } else {
            return $arr[0] * 60 + $arr[1];
        }
    }

?>