tl;dr
date_diff=$(( ($(date -d "2015-03-11 UTC" +%s) - $(date -d "2015-03-05 UTC" +%s)) / (60*60*24) ))
Watch out! Many of the bash solutions here are broken for date ranges which span the date when daylight savings time begins (where applicable). This is because the $(( math )) construct does a 'floor'/truncation operation on the resulting value, returning only the whole number. Let me illustrate:
DST started March 8th this year in the US, so let's use a date range spanning that:
start_ts=$(date -d "2015-03-05" '+%s')
end_ts=$(date -d "2015-03-11" '+%s')
Let's see what we get with the double parentheses:
echo $(( ( end_ts - start_ts )/(60*60*24) ))
Returns '5'.
Doing this using 'bc' with more accuracy gives us a different result:
echo "scale=2; ( $end_ts - $start_ts )/(60*60*24)" | bc
Returns '5.95' - the missing 0.05 being the lost hour from the DST switchover.
So how should this be done correctly?
I would suggest using this instead:
printf "%.0f" $(echo "scale=2; ( $end_ts - $start_ts )/(60*60*24)" | bc)
Here, the 'printf' rounds the more accurate result calculated by 'bc', giving us the correct date range of '6'.
Edit: highlighting the answer in a comment from @hank-schultz below, which I have been using lately:
date_diff=$(( ($(date -d "2015-03-11 UTC" +%s) - $(date -d "2015-03-05 UTC" +%s) )/(60*60*24) ))
This should also be leap second safe as long as you always subtract the earlier date from the later one, since leap seconds will only ever add to the difference - truncation effectively rounds down to the correct result.