Need to caculate the time difference.

March 20, 2010 at 00:02:21
Specs: Unix
Hi All,

I have a file which contains two lines as below :

Thu Mar 18 19:23:46 EDT 2010: exeStoredProc.sh (info) OSA_rule.bteq D031810.T190447 993210020
Thu Mar 18 19:47:03 EDT 2010: exeStoredProc.sh (info) rc=0


I need to calculate the difference between the highlighted time values in day hh:mm:ss or hh:mm:dd format or in seconds format . Is it possible to do in Unix. If so please let me know how can we do that.

Thanks,
Satya Ranjon


See More: Need to caculate the time difference.

Report •

#1
March 20, 2010 at 18:21:22
The easiest way is to parse the year, month, day, hour, min, and second from the string and then determine the number of seconds from the epoch. Then subtract the two epochs to get the total number of seconds between the two dates.

I use Perl to determine the actual epoch calcuation. This link is an example:

http://www.computing.net/answers/un...

The above example has a date string with a different structure, but it should be enough to get you started.


Report •
Related Solutions


Ask Question