It's easy to solve this problem under Linux
Date + "%y%m%d"-D "+n days" today's post N day dates
Date + "%y%m%d"-D "-N days" today's top N Day dates
There is no '-d ' option under UNIX, so the above method cannot be used
See on the web that there is a time zone to adjust echo ' tz=aaa16 date +%y%m%d\%h:%m:%s '
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/55/41/wKioL1SJRw-SVPgqAABsRlV7ohg264.jpg "title=" Qq20141211152119.png "alt=" Wkiol1sjrw-svpgqaabsrlv7ohg264.jpg "/>
Note:date printing is not the time of the local time zone, but the standard time, both London time.
London in the West District, Beijing in the East eight district, the difference between eight time zones.
TZ is a system environment variable that records the time zone in which the system resides, the AAA can be any string, and 16 represents the time difference from standard times.
Input Env|grep TZ Output tz=eat-8
Similarly, by Echo ' tz=aaa-32 date +%y%m%d\%h:%m:%s ' can get date after day
Above two is a relatively simple method of obtaining , if you think this method is not very reliable, you can write a shell script, the following self-written can refer to the following
#!/bin/sh# Enter the date parameter, do not enter the default day if [ $# -eq 1 ]then today=$1else today= ' date +%y%m%d ' fi# get date year= ' echo $today |cut -c 1-4 ' month= ' echo $today |cut -c 5-6 ' day= ' echo $today |cut -c 7-8 ' if [ $day -eq 1 ]then month= ' expr $month - 1 ' #月份减一后如果为0则为上一年, Month 12, year minus one [ $month -eq 0 ] && month=12 && year= ' expr $year - 1 ' #获取年月日历 aaa= ' cal $month $year ' #获取最后一天 day= ' echo $aaa |awk ' {print $NF} ' Else day = ' expr $day - 1 ' fi# if the date is only one then the former 0expr $day : "^.$" > /dev/null && day=0$dayexpr $month : "^.$" > /dev/null && Month=0$monthlastdate= $year$month$dayecho "lastdate=" $lastdateyear = ' echo $today |cut -c 1-4 ' month= ' echo $today | Cut -c 5-6 ' day= ' echo $today |cut -c 7-8 ' aaa= ' cal $month $year ' bbb= ' echo $AAA |awk ' {print $NF} ' [ $bbb -eq $day ] && month= ' expr $month + 1 ' && day=0[ $month -gt 12 ] && month=1 && year= ' expr $year + 1 ' day= ' expr $day + 1 ' expr $day : "^.$" > /dev/null && day=0$dayexpr $month : "^.$" > /dev/null && month=0$monthnextdate= $year $month$dayecho " Nextdate= "$nextdateexit 0
Unix gets the day after the day before the date