Compare two time (HH:MM:SS) - ksh

Is it possible to compate two time (24-hour format)?

What I need is to just check if the first time is earlier than the second time.

ex:

./script.ksh 09:30:15 13:00:34 = okay

./script.ksh 05:25:00 02:30:50 = invalid arguments

Convert the time stamp into number of seconds from epoch and then its a simple numerical comparison. Doing so is left as an exercise to the OP :slight_smile:

1 Like