Recording time difference between input0 and input1

I edited your post as <CODE> is not the right code tag for proper formatting. (Thanks for trying at least).

Why do you calculate the voltage ? Everything seems linear so you would save time by working from the raw values.

So you want to measure if a value is above a certain threshold for a certain time.

The algorithm is pretty simple

Set a flag to false initially (in setup)

In the loop
Calculate the value

If the value goes over the threshold and the flag was not set then set up the flag to true and mark the time (record millis value in a startTime variable)

If the value is below the threshold set the flag to false

If the flag is true check the difference between the current time and the recorded startTime and if it’s above your target duration take action

You’ll have to decide what to do after taking action - do you keep repeating or you await for the value to go back under the threshold before starting a new cycle

This is a simple state machine. Here is a small introduction to the topic: Yet another Finite State Machine introduction