if [[ -n $DAYS_OFF ]] # check for non-zero string
then
((OFFSET = 24 * $DAYS_OFF)) # calculate in 24h format
TZ="$TZ+$OFFSET" # change timezone
backdate=`date +%d/%m/%y` # get the desired date
echo $backdate
fi
exit 0
You call the script like that:
./x_days_back.ksh 1 (for yesterday)
./x_days_back.ksh 3 (date three days back)
I hope I could help you with that explanation of TZ.
but it seems that this command permanently sets the 'date' as yesterday.
Is there a way to reset the time after having done the above in a scripts, so I can use it again later with the same results as earlier (in the same scripts)? The reason is the script runs several sql statements that are date dependant.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.