The date command does not have the-D option in the AIX system and does not receive the entered value.
In an AIX system, if you want to get a few days or days after the current time, you can use the method that changes the current timezone.
Export Tz=beist-8 is the system current time.
Adjusting the time zone can change times.
For example: Get the time of next week export tz=beist-176, 176 is obtained by (24*7+8)
Gets the time of the previous week export tz=beist+160, 160 is obtained by (24*7-8)
Adjusting the time zone only changes the current window, but it has no effect on the server, but it is recommended that the time zone be adjusted back (export tz=beist-8) with no effect on the system.
The functions are as follows:
Daysafter ()
{
# $1:the number of days before or after today
# $2:the Format of date
Currenttz= ' echo $TZ '
if (($ > 0))
Then
Timezonediff= ' echo 24*$1+8 | BC '
Export tz=beist-$TimeZoneDiff
Elif (($ = 0)); then
:
Else
timezonediff= ' Echo-24*$1-8 | BC '
Export tz=beist+ $TimeZoneDiff
Fi
Date + "$"
Export tz= $CurrentTZ
}
Test:
$ daysafter 0 "%y-%m-%d%T"
2011-06-02 10:37:11
$ daysafter 7 "%y-%m-%d%T"
2011-06-09 10:37:29
$ daysa Fter-7 "%y-%m-%d%T"
2011-05-26 10:37:40