mktime problem

I am using mktime function to convert time from UTC to local time.

All is going well until the year changes. Apparently mktime convert the year to the system current year and not year passed in the time_t struct.

For example if i input the year of 2008 it will return the year 2007.

I am using the following code:

[code]

time_t ltime;

ltime = time(NULL);

newtime = localtime(&ltime);

newtime->tm_mday = atoi(year) - 1900;

newtime->tm_mday = atoi(day);

newtime->tm_mon= atoi(month)-1;

newtime->tm_hour = atoi(hour);

newtime->tm_min= atoi(min);

newtime->tm_sec= 0;

newtime->tm_isdst = 0;

ltime = mktime(newtime);

strftime(buf ,15 , "%Y%m%d%H%M",newtime);

[/code]

Can someone tell me how solve this problem? or an alternative form to convert dates from UTC to local time.

Thanks in advance.

[934 byte] By [13Scorpioa] at [2007-11-26 13:54:22]
# 1
Perhaps you should try: newtime->tm_year = atoi(year) - 1900;instead of: newtime->tm_mday = atoi(year) - 1900;
hertega at 2007-7-8 1:32:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
Thanks ;)That was a copy paste error. Already tested the new code and it works fine.
13Scorpioa at 2007-7-8 1:32:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...