Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

difference of time

Status
Not open for further replies.

handle1programmer

Programmer
Jun 26, 2002
1
US
Hi,

I have 2 dates : d1 and d2 which display time also
in the format Wed 20 Jun 2002 10:10:10 . How can i get
the difference of these 2 date-times using shell
scripting.

Thanks
 
Does this have to be done in bash script? If not you could use a Perl script using the Fate::Calc module. This will allow date arithmetic using dates in all kinds of wierd formats.

use Date::Calc qw(Delta_DHMS);
@date1 = (1992, 3, 24, 10, 10, 0);
@date2 = (2002, 5, 23, 12, 4, 0);
@diff = Delta_DHMS(@date2, @date1);
printf "Difference is $diff[0] days, $diff[1]:$diff[2]:$diff[3]\n";

or some variation on that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top