in reply to Getting avg start time
sometimes, the start time will cross midnightBut the dates you've used are on three different days! change the last date to the 9th and you get a very reasonable average of 1:00.
use Date::Calc qw(Date_to_Time); use POSIX; my $time1 = Date_to_Time(2007,8,8,23,00,0); my $time2 = Date_to_Time(2007,8,9,03,00,0); my $time3 = Date_to_Time(2007,8,9,01,00,0); print "$time1\t$time2\t$time3\n"; my $avg = sprintf "%0.0f", (($time1+$time2+$time3)/3); print "$avg\n"; print strftime "%H:%M:%S\n", gmtime($avg); __END__ 1186614000 1186628400 1186621200 1186621200 01:00:00
|
|---|