Thursday, August 22, 2013

Script converting seconds to time format

Here is simple script to convert seconds to time (hh:mm:ss) format.

#!/bin/bash
convertsectotime() {
 ((h=${1}/3600))
 ((m=(${1}%3600)/60))
 ((s=${1}%60))
 printf "%02d:%02d:%02d\n" $h $m $s
}
#TIME1="36"
echo "enter seconds:"
read TIME1
echo $(convertsectotime $TIME1)