你可以很容易地做到这一点,只使用核心功能。
#!/usr/bin/perl
use strict;
my $new_time = 1350570164; # 2012-10-18 14:22:44
my $older_time = 1350450164; # 2012-10-17 05:02:44
printf "time in sec: %d older that 24 hours: %d\n", $new_time, is_time_older_24($new_time);
printf "time in sec: %d older than 24 hours: %d\n", $older_time, is_time_older_24($older_time);
sub is_time_older_24 {
my $given_time = shift;
my $yesterday_time = time() - 60 * 60 * 24;
return $given_time <= $yesterday_time
? 1
: 0;
}
输出:
time in sec: 1350570164 older that 24 hours: 0
time in sec: 1350450164 older than 24 hours: 1