char newDate[10];
time_t lt=time(NULL); //get seconds from 1970.1.1 00:00:00 in gmt
lt-=7*3600; //minus 7*3600 seconds
struct tm *ptr=localtime;
strftime(newDate, 10, "%G%m%d", ptr); //get local time from lt
這裏不能用ptr->tm_hour+=7;因爲,這不會對天數等進行相應修改,且小時 會超過24
c語言的函數用法流程是:
time --> gmtime/localtime --> strftime
time --> gmtime/localtime --> astime
time --> ctime