in reply to Comparing two dates and getting back difference in days

Greetings all,
A little late I know but here is what I use for small cases.
#!/usr/bin/perl -w use strict; use Time::Local; my $start_date_str = "2004-01-14";#date you are testing; my ($year,$month,$day) = split(/\-/,$start_date_str); $month--;#timelocal months are 0-11; my $start_seconds = timelocal(0,0,0,$day, $month, $year); my $today_seconds = time(); my $days_between = ( int( ( ( (abs($start_seconds - $today_seconds))/6 +0 )/60 )/24 ) ); print $days_between; exit;
Previewing it I must admit its not very elegant, but it works for me.
Hope that helps get you part of the way there.

Replies are listed 'Best First'.
Re^2: Comparing two dates and getting back difference in days
by rementis (Beadle) on Mar 28, 2024 at 18:17 UTC
    This is great code, thanks!