use HTTP::Date; my $start_time = str2time('2005-10-01 22:00:00'); my $end_time = str2time('2005-10-02 04:00:00'); my $check_time = str2time('2005-10-01 22:40:00'); if ($start_time < $end_time) { if ($start_time < $check_time and $check_time < $end_time) { print "yes\n"; } else { print "no\n"; } } elsif ($end_time < $start_time) { if ($end_time < $check_time and $check_time < $start_time) { print "yes\n"; } else { print "no\n"; } } else { print "Start and End times are identical\n"; }