自C ++开始以来的几个月

时间:2015-12-06 21:11:16

标签: c++ algorithm time

如何在C ++中获取自月份开始以来的秒数?

我只是想知道如何思考这样一个问题的算法

我想我知道正确的方法,但我没有合适的工具来解决它

我已经采取过这种方式:

                time_t rawtime1, rawtime2;                  //Time type

                struct tm * timeinfo;                       //Time structure

                time(&rawtime1);                            //to Get current time

                time(&rawtime2);                            //to Get current time

                timeinfo = localtime(&rawtime2);            //Convert time_t to tm as local time

                //setting up in rawtime2 to the beggining of this specific month - like a reset to 0 in month and days

                //now will convert rawtime2 to seconds with mktime

                return rawtime1 - rawtime2;

感谢提前!!

0 个答案:

没有答案