Dear there,
mktime() didn't work? please take a close look at the outpout, which shows that "tt=-1", while "ft" has been assigned value by mktime. And how could both says in year 2000? Apprantly I want one year in 2000, another in 2050. Any ideas? Thanks!
Code:
int main(int argc, char **argv){
struct tm f;
struct tm t;
time_t ft;
time_t tt;
//2000-1-1 00:00:00
f.tm_sec = 0;
f.tm_min = 0;
f.tm_hour = 0;
f.tm_mday = 1;
f.tm_mon = 0;
f.tm_year = 100;
f.tm_gmtoff = 0;
//2050-1-1 00:00:00
t.tm_sec = 0;
t.tm_min = 0;
t.tm_hour = 0;
t.tm_mday = 1;
t.tm_mon = 0;
t.tm_year = 150;
t.tm_gmtoff = 0;
ft = mktime(&f);
tt = mktime(&t);
printf("get all records from %s\t%ld \n to %s\t%ld\n", asctime(&f), ft, asctime(&t), tt);
}
output:-------------------------------------------------------------------
get all records from Sat Jan 1 00:00:00 2000
946702800
to Sat Jan 1 00:00:00 2000
-1