Difference between two timestamps

I'm writting a script to find the difference between two timestamp. One field i get on delivery time of the file like 07:17 AM and other is my SLA time 06:30 AM

I need to find the difference between these two time (time exceeded to meet SLA). Need some suggestions.

Can you post your script so that we can suggest the changes required ?

expectedSLA='06:30'

time= `autorep -j $i | grep SU | awk '{print $6}'` #gives the delivery time

#need to find difference between these timings

modify this script as per your need.

echo enter first time stamp
read TIME1
echo enter second time stamp
read TIME2
gnud1=`date -d "$TIME1" +%s`
gnud2=`date -d "$TIME2" +%s`
sla=`expr $gnud2 - $gnud1`
echo $sla

Output:

Any use ?

Thanks a lot....This will help...

get this error when i try to run this script

date: illegal option -- d

Please suggest

Try this one:

$ cat timestamp
#! /usr/bin/ksh

echo enter first time stamp
read TIME1
echo enter second time stamp
read TIME2
H1=${TIME1%:+([0-9])}
M1=${TIME1#+([0-9]):}
H2=${TIME2%:+([0-9])}
M2=${TIME2#+([0-9]):}
H1=${H1#0}
M1=${M1#0}
H2=${H2#0}
M2=${M2#0}
((MAM1=H1*60+M1))
((MAM2=H2*60+M2))
((MAM1>MAM2)) && ((MAM2=MAM2+1440))
((diff=MAM2-MAM1))
echo diff = $diff

exit 0
$ ./timestamp
enter first time stamp
17:30
enter second time stamp
18:05
diff = 35
$ ./timestamp
enter first time stamp
23:59
enter second time stamp
00:01
diff = 2
$

syntax error at line 5: `H1=${TIME1%:+' unexpected

i'm using :: /bin/csh

You need to use ksh for my script. My sure the first line is as I have it and make the script executable. Then even if you run it from csh, ksh will run my script.