1.直接调用shell脚本
afterdata=$(date -d +1day "+%Y%m%d")
2.C语言获取后几天time
#include <stdio.h>
#include <time.h>
#include <string.h>
int main(int argc,char const *argv[])
{
char yestDt[9];
time_t now = time(NULL);//获取1970.1.1到目前经过的秒数
struct tm *ts = localtime(&now);//获取本地时间(与时区相关)
ts->tm_mday++;
mktime(ts);//将ts转换为经过的秒数
strftime(yestDt,sizeof(yestDt),"%Y%m%d",ts); //输出格式加个%T等同于%H%M%S
printf("Yesterday is "%s"
",yestDt);
return 0;
}