Year problem

31 Oct 2010

Hi,

I'm having problems with decoding the month and year...

today  Sun Oct 31 19:15:01 2010, gives as result da:31,mo:9,ye:110

tm * timeinfo;

ctTime = time(NULL);
timeinfo = localtime(&ctTime);

da=timeinfo->tm_mday;
mo=timeinfo->tm_mon;
ye=timeinfo->tm_year;

Anybody a solution?

 

 

31 Oct 2010 . Edited: 31 Oct 2010

hi

->tm_year is years since 1900

so try

ye=timeinfo->tm_year + 1900;

 

see here

Matt

31 Oct 2010

year is based on 1900 "epoch". Just add 1900 to tm_year to get correct year, i.e. 110+1900 = 2010.