Can some one help me getting last hour of the current time with date command in a script.
date +%H -d "1 hour ago"
Just giving me 08...i want it like if its 8:00 i want to show 7:00 but i want it in an YYYYMMDDHH format.
date "+%Y%m%d%H" -d "1 hour ago"
Regards
Try this :
TZ=GMT+x date +%Y%m%d%H
where x is the time u r behind(+) or ahead(-) of GMT + 1
one final question..how can should this in a shell script if i wanna use TZ?
var=`TZ=GMT+5 date +%Y%m%d%H`
If GNU date is not available to you and you are using ksh93
var=$(printf "%(%Y%m%d%H)T" "1 hour ago")