How to find the difference between two dates in bash

This article explains the way to find the difference between two dates in bash.

day1=`date +%s -d "2022-01-01"`
day2=`date +%s -d "2022-01-10"`

DIFF=`expr \( $day2 / 86400 \) - \( $day1 / 86400 \)`
echo $DIFF

Here we need to replace the required date strings in day1 and day2.

That's all…