This snippet will return the number of seconds you've been on a channel.
There are comments and examples included with the code.
/*
$joined()
Usage: $joined(#channel)
Explanation: returns the number of seconds you've been on #channel.
*/
alias joined { return $iif($calc($ctime - $hget(joined $+ $cid,$1)) < $ctime,$v1,0) }
on *:disconnect:{
if ($hget(joined $+ $cid)) { hfree $v1 }
}
on me:*:join:#:{ hadd -m joined $+ $cid $chan $ctime }
on me:*:part:#:{
if ($hget(joined $+ $cid,$chan)) { hdel joined $+ $cid $chan }
}