PDA

View Full Version : error using mktime



amit_sahrawat
12-04-2007, 05:33 AM
I am trying to get a time_t structure value from mktime() but it returns (time_t)-1.
I am doing something like this:
struct tm tv;
time_t timvar;
memset() for both the variables:
tv.tm_year = 2007;
tv.tm_mon=12;
tv.tm_mday=4;
tv.hour=16;
tv.tm_min=0;
tv.tm_sec=0;
timvar= mktime(&tv);
it returns,
Wed Dec 31 23:59:59 1969 (FFFFFFFF)

Any help?
Thanks & Regards,
Amit Sahrawat

matsp
12-04-2007, 05:38 AM
Perhaps you want to give "year-1900", as that's what the man-page says:
http://www.hmug.org/man/3/mktime.php

--
Mats

amit_sahrawat
12-04-2007, 06:03 AM
got it ... yups it has to be year -1900, and so is for other values...

Thanks,
Amit Sahrawat