×

Loading...

It came with every Linux distro (I think). I mean date(1) in Linux (which is from FSF) is different from date(1) in *BSD. And I think $(( ... )) will do the same thing with expr? I'm using bash anyway.

Actually my script has problems, it overflows much earlier than it should be. Here's an updated one:

#!/bin/sh

s1=`date -d $1 +%s`
s2=`date -d $2 +%s`
day1=$(($s1/3600/24))
day2=$(($s2/3600/24))
echo "Days: " $(($day2 - $day1))

But like I said it can only calculate from 1902 - 2038. I'll try to come up one with awk (why I didn't think of that? stupid me) if I have time. But I have to deal with leap year myself I guess.
Report