- 论坛徽章:
- 0
|
#include <stdio.h>
#include <time.h>
int main()
{
time_t now;
time_t tmp;
struct tm p_tm;
int days = 20;
char buff[1024];
tmp = 20*24*60;
time(&now);
localtime_r(&now,&p_tm);
sprintf(buff,"%04d-%02d-%02d.log",p_tm.tm_year+1900,p_tm.tm_mon+1,p_tm.tm_mday);
printf("%s\n%u\n%u\n",buff,now,tmp);
now -= tmp;
localtime_r(&now,&p_tm);
sprintf(buff,"%04d-%02d-%02d.log",p_tm.tm_year+1900,p_tm.tm_mon+1,p_tm.tm_mday);
printf("%s\n%u\n",buff,now);
return 0;
} |
为什么我减了时间之后通过localtime_r得到的值转化以后是一样的啊,print的值是一样的 |
|