## Calculate the difference betwwn two times

## Calculate the difference betwwn two times

(OP)

I'm trying to determine the time difference between the current time and when a print job was created. I'm using the 6th field in lpstat -o to collect the time the print job was created as follows: lpstat -o returns this:

LP07-48943 root 476 Sep 21 10:49

So $6 = 10:49

If the current time (date +%H) = 12:11, how can I determine the number of seconds between the two? I've been away from this type of programming for too long and I'm running in circles. Any help or suggestions will be greatly appreciated.

BTW - the OS is SCO. (I know, I know...)

LP07-48943 root 476 Sep 21 10:49

So $6 = 10:49

If the current time (date +%H) = 12:11, how can I determine the number of seconds between the two? I've been away from this type of programming for too long and I'm running in circles. Any help or suggestions will be greatly appreciated.

BTW - the OS is SCO. (I know, I know...)

## RE: Calculate the difference betwwn two times

Does SCO's date have -d option similar to GNU date ?

If yes, then I would use it to parse the entire date part of lpstat into Unix time then calculate with that :

## CODE

Feherke.

feherke.github.io

## RE: Calculate the difference betwwn two times

If you are more into Awk and GNU awk is available on SCO, you can do it all with that :

## CODE

Feherke.

feherke.github.io

## RE: Calculate the difference betwwn two times

Or you can just compose the formula and evaluate it :

## CODE

Feherke.

feherke.github.io

## RE: Calculate the difference betwwn two times