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
In reply to Re: Best way to compare date strings
by davorg
in thread Best way to compare date strings
by minixman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |