strftimedoesnt display year correctly

Posted by paultop6 on Stack Overflow See other posts from Stack Overflow or by paultop6
Published on 2010-04-05T14:29:01Z Indexed on 2010/04/05 14:33 UTC
Read the original article Hit count: 182

Filed under:
|
|

Hi guys, i have the following code below:

const char* timeformat = "%Y-%m-%d %H:%M:%S";
const int timelength = 20;
char timecstring[timelength];

strftime(timecstring, timelength, timeformat, currentstruct);

cout << "timecstring is: " << timecstring << "\n";

currentstruct is a tm*. The cout is giving me the date in the correct format, but the year is not 2010, but 3910. I know there is something to do with the year cound starting at 1900, but im not sure how to get strftime to recognise this and not add 1900 to the value of 2010 that is there, can anyone help.

Regards

Paul

© Stack Overflow or respective owner

Related posts about datetime

Related posts about time