Php check if digit time is greater than other digit time

32 views Asked by At

I have an array of digit time numbers (I get them from the input fields).

Here are a few examples:

00:00:10
00:03:00
01:20:00

My question is following, how do I check if a digit time is greater than another?

Following function works up to

00:01:00

After that I get an error.

$inputTimes = $request->input('times', []);

foreach ($inputTimes as $inputKey => $inputValue)
{
    $Input = new Input();
    $Input->input_start = $inputValue['input_start'];

    $tInput     = explode(':', $inputValue['input_timelapse']);
    $implInput  = implode('', $tInput);
    $iImplInput = (int)$implInput;

    // Check if time is greater
    if($iImplInput > $iVideoDuration)
    {
    .. error time greater
    }
}
1

There are 1 answers

2
AudioBubble On

I would convert it to Unix time by using the inbuild strtotime() function.

For example: strtotime('01:20:00'); will output 1483492800 while strtotime('00:01:00'); will output 1483488060.

Hope this helped.