SLUG Mailing List Archives
Re: [SLUG] Change seconds to H:M:S
- To: georgev@xxxxxxxxxxxxxxxxxxxxxx
- Subject: Re: [SLUG] Change seconds to H:M:S
- From: davidf@xxxxxxxxxxxxxxxxxx (Dave Fitch)
- Date: Wed Sep 6 11:47:00 2000
- Cc: slug@xxxxxxxxxxx
George Vieira <georgev@xxxxxxxxxxxxxxxxxxxxxx>
> I have PPPD running and sending out via $CONNECT_TIME variable the time the
> link was up for. The problem is that it's in seconds only and I get rsults
> like "37646752 seconds". Is there a way to convert this into H:M:S?
> I am doing this in a bash script..
divide by 60 for minutes and 3600 for hours (but you knew
that I guess!).
eg. (only shows integer values but you get the idea)
if [ $connect_time -lt 61 ]; then
echo "connected for $connect_time seconds"
elif [ $connect_time -gt 60 -a $connect_time -lt 3601 ]; then
connect_minutes=`expr $connect_time '/' 60`
echo "connected for $connect_minutes minutes"
connect_hours=`expr $connect_time '/' 3600`
echo "connected for $connect_hours hours"
to do H:M:S you need to get more fancy with mods and remainders
and so on (mod is "%" in sh, not sure about remainder).