Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How can I calculate the time difference from for example 28/08/03 04:23:18 and 29/08/03 13:18:48. Is there any time function for this purpose?

I use this PERL module for various date/time functions.
The following script uses the module linked above. Note that you have to escape the space in your date/times so each date is only one argument. I called the script like this (in BASH)- "./test.pl 28/08/03\ 04:23:18 29/08/03\ 13:18:48".
#!/usr/bin/perl
use Date::Manip;
$date1 = $ARGV[0];
$date2 = $ARGV[1];
$date1 =~ m/(\d{2})\/(\d{2})\/(\d{2}) (\d{2})\:(\d{2})\:(\d{2})/;
$secs1 = Date_SecsSince1970( $2, $1, "20$3", $4, $5, $6 );
$date2 =~ m/(\d{2})\/(\d{2})\/(\d{2}) (\d{2})\:(\d{2})\:(\d{2})/;
$secs2 = Date_SecsSince1970( $2, $1, "20$3", 4, $5, $6 );
$diff = $secs2 - $secs1;
print "difference is: $diff seconds";

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |