monkfan has asked for the wisdom of the Perl Monks concerning the following question:
My problem is how can I find/print out the time difference (in seconds) for starting time and current time? Namely the time difference of:use Data::Dumper; use Carp; use Proc::ProcessTable; use Time::Local::Extended qw(:ALL); $FORMAT = "%-6s %-8s %-24s \n"; $t = new Proc::ProcessTable; my $now = localtime; print "NOW: $now\n"; printf( $FORMAT, "PID", "START", "TIME_DIFF" ); foreach $p ( @{ $t->table } ) { my $start = $p->start; #my $diff = $start - $now; #doesn't seem to work my $diff = 1000; # this is just a dummy printf( $FORMAT, $p->pid, scalar( localtime( $p->start ) ), $diff ); }
andmy $now = localtime;
scalar( localtime( $p->start ) )
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Finding Time Difference of Localtime
by Corion (Patriarch) on Oct 25, 2007 at 15:13 UTC | |
by Aldebaran (Curate) on Dec 01, 2019 at 00:42 UTC | |
by Corion (Patriarch) on Dec 01, 2019 at 08:01 UTC | |
by Aldebaran (Curate) on Dec 03, 2019 at 19:56 UTC | |
Re: Finding Time Difference of Localtime
by kyle (Abbot) on Oct 25, 2007 at 15:12 UTC | |
Re: Finding Time Difference of Localtime
by lorn (Monk) on Oct 25, 2007 at 15:16 UTC | |
by RaduH (Scribe) on Oct 25, 2007 at 15:20 UTC |