perl 计算时间间隔

#计算时间间隔
sub gettimemun(){
   my ($time,$timelc,$sec,$min,$hour,$mday,$mon,$year);
   $time = @_[0];
   my @time = reverse(split /-|:|\s|\//,$time);
   foreach(@time){
   s/^0//;
   $timelc .= $_.",";
   }
   $timelc =~ s/,$//;
   ($sec,$min,$hour,$mday,$mon,$year) = split /,/,$timelc;
   $year -= 1900;
   $mon -= 1;
   $timelc = timelocal($sec,$min,$hour,$mday,$mon,$year);
   return $timelc;
}
#计算天数(比较的时间格式: 2011-11-10 15:37:58)
$SECOND_OF_ONE_DAY=24*60*60;
$days= int((&gettimemun($nowtime) - &gettimemun($oldtime))/$SECOND_OF_ONE_DAY);

你可能感兴趣的:(perl)