Deane-

let me first copy the substance from your email to cite it right


****quote*****
A simple one: what's the best, quickest, way to get the difference between 

two dates. They're both in the same format: "YYYYMMDD". One of them gets 
ginned up into that format starting from a call to localtime (that is, @x 
= localtime; stuff happens to @x; $y ends up "20051031";), the other's 
read in as a string from a file.
****quote*****


ok well 
my $time = localtime();   returns : Mon Oct 31 15:35:34 2005

which is nice when you're doing a report for a human, but not for 
differences. 

aside from checking date/time modules that exist, i would suggest looking 
into converting to epoch. at this point it is in seconds since midnight 
Jan 1 1970. from there you find the difference and then you have the 
seconds difference. converting to another form is as simple as:

----pseudocode ---

$t1 = localtime();
$t2= <read in time>;
$t3=convert($t1, epoch);
$t4=convert($t2, epoch);

$seconds_difference=$t3-$t4;
$minutes_difference=$seconds_difference/60;
$hours_difference=$minutes_difference/60;
$days_difference=$hours_difference/24

----pseudocode ---

not sure of the built in converter off the top of my head. figure I'd show 
you what I'd do and you can decide if it will work for you.

HTH

-josh
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to