Subtract Time

Hello,

Im writing a script using the ksh shell. I have 2 variables in the script:

CURRTIME
PREVTIME

Example, if CURRTIME=13:00, I want to somehow calculate what the time was an hour ago so that PREVTIME=12:00

Right now I have the following:

CURRTIME=`date +%H:%M`

How can I determine PREVTIME based on the CURRTIME?

You never mentioned which OS.

Here is GNU date option.

-bash-2.05b$ date
Thu Dec  1 19:59:45 PST 2005
-bash-2.05b$ date -d "1 hour ago"
Thu Dec  1 18:59:50 PST 2005

The OS is Digital Unix and Tru64 Unix. I wont be able to test your command until Monday. Do you know if it works on those OSes?

I doubt it. But with ksh:
typeset -Z2 prevhour=$(((${CURRTIME%???}+23)%24))
PREVTIME=${prevhour}${CURRTIME#??}

Thank you very much Perderabo, but I realized something after I posted my question. I need the format of the date to be '02-dec-2005:15:30'. I need to have the date included so my script will work after midnight on the next day. Do you have any idea how to accomplish that?