Here a simple ksh function to get any date in the past or in the future from today.
It takes two arguments, the first is mandatory and is the number of days from today (negative for backward) and the second one is optional and is the format you want the date command uses.
Code:
GetDate(){ # GetDate nDays [format]
typeset -i nDays=$1; format=$2
typeset -i localOffset=$(echo $TZ |
sed 's![^-0-9]*\([-0-9]*\).*!\1!')
TZ=X$((localOffset-24*nDays)) date $format
}
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.