C++ Time returned is two hours out

后端 未结 2 953
天涯浪人
天涯浪人 2021-01-22 13:15

Bit of a c++ newbie so here we go;

I have a method that is parsing a date/time, however that date/time is passed to me always with 00:00:00 as the hh:mm:ss. As such i wa

2条回答
  •  执念已碎
    2021-01-22 13:44

    The reson is the mktime() method used in the first function uses local time, but gmtime() uses UTC time.

    See http://www.cplusplus.com/reference/clibrary/ctime/mktime/ and http://www.cplusplus.com/reference/clibrary/ctime/gmtime/ for further explanation.

提交回复
热议问题