in reply to Best way to compare date strings
Use the DateTime family of modules.
#!/usr/bin/perl use strict; use warnings; use DateTime::Format::Strptime; my $fmt = DateTime::Format::Strptime->new(pattern => '%Y/%m/%d %H:%M:% +S:%3N'); my $date1 = $fmt->parse_datetime('2006/01/03 03:59:59:671'); my $date2 = $fmt->parse_datetime('2006/01/03 04:00:00:562'); my $diff = $date2 - $date1; print $diff->in_units('nanoseconds'), "\n";
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best way to compare date strings
by minixman (Beadle) on Jan 04, 2006 at 12:36 UTC | |
by minixman (Beadle) on Jan 04, 2006 at 12:50 UTC | |
by davorg (Chancellor) on Jan 04, 2006 at 16:59 UTC |