Get date and time for past 1 hour from current date

Hi,

I need to get the date and time for past 1 hour from the current date. Anyone know how to do so?

Thanks

One way:
$ perl -e '@d=localtime time()-3600; printf "%4d%02d%02d%02d%02d%02d\n", $d[5]+1900,$d[4]+1,$d[3],$d[2],$d[1],$d[0]'
20071220220154

Another nce way is setting up a new variable (you can adjust the number of hours by changng the +n value previous day is +24)

-bash-3.00$ NEWDATE=`TZ=GMT+2 date +%Y-%m-%d" "%H:%M:%S`
-bash-3.00$ echo $NEWDATE
2007-12-21 09:57:09
-bash-3.00$ date
Fri Dec 21 11:57:17 GMT 2007
-bash-3.00$

if you have GNU date

# date +%Y%m%d%H%M%S -d  "1 hour ago"
20071221193551

FreeBSD

date -v -1H "+%Y-%m-%d %H:%M:%S"

nhatch -- That's the most elegant solution on these boards.

This is exactly what I was looking for. (How to subtract x number of hours from today's date/time.

Thanks again