How to find the difference between epoc dates in HH:MM:SS?

How to find the difference between below epoc dates in HH:MM:SS

1557863573 converts to Tuesday May 14, 2019 21:52:53 (pm) in time zone Europe/Amsterdam (CEST)
1557866394 converts to Tuesday May 14, 2019 22:39:54 (pm) in time zone Europe/Amsterdam (CEST)

#!/bin/bash
set -x

A=1557863573
B=1557866394
time_diff=$A-`$B
time_diff_in_mins=echo "("$time_diff")/60" | bc
echo $time_diff_in_mins

Thanks

So, apart from your script not running flawlessly for syntax errors, what doesn't work as desired? Where are you stuck?

1 Like

I guess the author of the topic is have lost intrest. I suggest to the post to continue life independently :slight_smile:

#!/bin/bash
declare -i time_diff time_diff_in_mins
A=1557863573
B=1557866394
time_diff=$B-$A
time_diff_in_mins=$time_diff/60
echo $time_diff_in_mins

#install dateutils

datediff -i "%A %B %d, %Y %H:%M:%S" "Tuesday May 14, 2019 21:52:53" "Tuesday May 14, 2019 22:39:54" -f %M
1 Like

With GNU date , and a recent bash , and above $time_diff , why not

date -d"@$((time_diff - 3600))" +%T
00:47:01

to get the HH:MM:SS format? Notabene: will fail at negative time differences or those larger than 23:59:59.

1 Like

Actually i was busy ...so was not able to work on it...
However i thank you all for keep helping beginners like me....:slight_smile: