1834935 Members
2188 Online
110071 Solutions
New Discussion

Re: Manipulating TIME

 
SOLVED
Go to solution
Rafael Mendonça Braga
Regular Advisor

Manipulating TIME

Hello There!
Using HP-UX 11i

Well, I have a problem calculating time... Everytime my script runs I need it to increase one more minute in the "TIME" variable...

I'm collecting "TIME" this way:

TIME=`date +%H:%M:%S`

So, after that i need to increase 1 minute in this TIME variable...For Ex:

If TIME = 14:26:32
I need it to become 14:27:32

Any ideas about how can I do it!?

Thanks

Rafael M. Braga
3 REPLIES 3
RAC_1
Honored Contributor

Re: Manipulating TIME

echo $TIME|awk -F " '{OFS=":";print $1,$2,$3}'
The catch is if minutes column is 60, you would increment hour feild and make second field to 0.

Anil
There is no substitute to HARDWORK
Mel Burslan
Honored Contributor
Solution

Re: Manipulating TIME

Instead, you can do this
HOUR=`date +%H`
MINUTE=`date +%M`
SECOND=`date +%S`

let NEW_MINUTE=${MINUTE}+1

if [ $NEW_MINUTE -eq 60 ]
then
NEW_MINUTE=00
let HOUR=${HOUR}+1
fi

if [ $HOUR -eq 24 ]
then
HOUR=00
fi

TIME=`printf ${HOUR}":"${NEW_MINUTE}":"${SECOND}`

hope this helps
________________________________
UNIX because I majored in cryptology...
Rafael Mendonça Braga
Regular Advisor

Re: Manipulating TIME

Thanks MEL...
10 for you!!