I have this date time format in string \"11:56:41, 11/22/2011\".
Here\'s what I want:
Compare two date time strings like.
$date1 = \"11:56:41
An efficient method is to reorder the fields to something lexically comparable.
sub to_comparable {
my ($date) = @_;
my ($H,$M,$S,$d,$m,$Y) = $date =~ m{^([0-9]{2}):([0-9]{2}):([0-9]{2}), ([0-9]{2})/([0-9]{2})/([0-9]{4})\z}
or die;
return "$Y$m$d$H$M$S";
}
if (to_comparable($date2) lt to_comparable($date1)) {
...
} else {
...
}