I have 2 strings s1 and s2 (representing dates) in bash of the form
s1="Fri Sep 10 22:24:51 IST 2021"
s2="Fri Sep 10 22:45:55 IST 2021"
I want to subtract these dates and get the result in the format HH:MM:SS
I have tried the following piece of code (to at least convert the strings to date)
d1=$(date -s $s1 +%s)
d2=$(date -s $s2 +%s)
d3=$d2-$d1
echo "$d3"
but ended up with the following error
date: extra operand ‘10’
This is the sample output I desire
Subtracted Date in HH:MM:SS is "00:21:04"
I am stuck here and don't know how to proceed further. Any help on this would be appreciated!