From the gmtime
documentation:
This structure is statically distributed and shared by gmtime and localtime. Each time one of these functions is called, the contents of this structure are overwritten .
Use this code to create a copy:
time_t tt = time(NULL); tm currentTime = *gmtime(&tt); tm storedTime = *gmtime(&m_time);
(the meaning of the pointer here is equivalent to memcpy(¤tTime, gmtime(&tt), sizeof(tm))
)
source share