In Feburary 2016 16,
Include the C++ standard library's time functionality into your application. Add the following line to the top of your include list:include
Obtain the seconds elapsed since the epoch, and store it locally. Do this by calling time(), and storing the result into an object of type time_t. The time function also accepts a pointer to an object of type time_t as an argument, but it is simpler to store this object locally on the stack:time_t timeSinceEpoch = time(NULL);
Create a time structure to store the result of the time conversion. This structure is defined in the time.h header file as a structure named tm, and provides conveniently-named member variables for each component of the converted time:tm timeResult;
Use one of the built-in conversion functions to store the time_t value obtained earlier as a tm structure. For simplicity, the following code converts a time_t object into a UTC tm structure:timeResult = gmtime( &timeSinceEpoch );
In Feburary 2016 16,
No comments:
Post a Comment