On Sun, Nov 21, 1999 at 07:02:13PM +0100, Lasar Liepins wrote: > Hi. > > I'm havin trouble finding some understandable information > on how to compare two dates. > > What I want to accomplish: > > >From a text log file I have extracted the minutes, hours, day, month and > year > for to points in time. Now I want to know how much time has passed between > them. > In my first beta of the script in which I need this I just used this: > > $time1 = $min1 + ( $hrs1 * 60 ); > $time2 = $min2 + ( $hrs2 * 60 ); > $connection_time = $time2 - $time1; > > not very pretty of course, and it doesn't account for things like > 23:55 to 01:05. > I guess I need a function that creates a timestamp from the parts I have, > and a function which calculates the minutes or hours of the intercal > between > the two times. > use Time::Local; # Module bundled with Perl $time1 = timelocal($sec1,$min1,$hours1,$mday1,$mon1,$year1); $time2 = timelocal($sec2,$min2,$hours2,$mday2,$mon2,$year2); $diff = $time2 - $time1; # difference in seconds $h = int $diff / 3600; # hours of difference $m = ($diff / 60) % 60; # minutes of difference Ronald # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org