Is there a way to compare two times (HH:mm:ss) and if a difference of X do Y or ELSE do Z.

Why I want this:

I want to send an email when a particular alert occurs, however, I only want to send this email if two alerts happen within specified time frame, i.e. 30 seconds.

I was thinking of writing the two times into an INI file and then reading the values but I can't figure out how to compare these times and return a value which I can then say is greater than or less than the specified value.

Hope this makes sense.

Thanks in advance