Hi Friend,
Here is what I did with my problem, may be you can gain from this:
1. In index.pl or your index.cgi, I have this 2 sub.
Code:
sub get_date2 {
# --------------------------------------------------------
# Returns the date in the format "Mmmm dd, yyyy hh:mm ".
# Warning: If you change the default format, you must also modify the &date_to_unix
# subroutine below which converts your date format into a unix time in seconds for sorting
# purposes.
my ($time) = @_;
($time) || ($time = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
($day < 10) and ($day = "0$day");
$mon += 1;
($mon < 10) and ($mon = "0$mon");
$year = $year + 1900;
if ($min < 10) {
$min = "0" . $min;
}
return "$mon\/$day\/$year $hour:$min:$sec";
}
sub date_to_unix2()
{
my ($mon,$day,$year,$hour,$min) =
$_[0] =~ /(\d+)\/(\d+)\/(\d+)\s(\d+):(\d+)/;
return undef unless ($day and $mon and $year);
return timelocal(0,$min,$hour,$day,$mon-1,$year-1900);
}
Then in my html.pl
I will add
Code:
# Calculate Down Time if we recived part.
my $epstart = (&date_to_unix2($rec{'Field1'}));
my $epreceive = (&date_to_unix2($rec{'Field2'}));
$diff = ($epreceive - $epstart);
$seconds = $diff % 60;
$diff = ($diff - $seconds) / 60;
$minutes = $diff % 60;
$diff = ($diff - $minutes) / 60;
$hours = $diff % 24;
$diff = ($diff - $hours) / 24;
$days = $diff % 7;
$totalday = $diff;
$weeks = ($diff - $days) / 7;
print qq|
<TD bgcolor=d3d3d3>$rec{'Field1'}</TD><TD bgcolor=d3d3d3>$rec{'Field2'} </TD><TD bgcolor=d3d3d3> $totalday days $hours:$minutes</TD>|;
Just look at this and you can do yours easily. OOp, remember to change the time format to the corect way of your style. Mine is mm/dd/yyyy
Good luck,