in reply to Comparing dates in Perl
use strict; use warnings; use feature qw( say ); use DateTime qw( ); use DateTime::Format::Strptime qw( ); my $format = DateTime::Format::Strptime->new( pattern => '%d-%m-%Y', time_zone => 'local', on_error => 'croak', ); my $target = $format->parse_datetime('05-08-2012'); my $today = DateTime->today( time_zone => 'local' ); say $today->delta_days($target)->in_units('days'); # 123
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing dates in Perl
by locked_user sundialsvc4 (Abbot) on Apr 04, 2012 at 21:39 UTC | |
|
Re^2: Comparing dates in Perl
by DaveMonk (Acolyte) on Apr 08, 2012 at 20:07 UTC |