From: http://maxim.eefocus.com/xuefu2009/blog/10-03/187348_f456a.html
Include files
: # Ifndef _ time_t # DEFINE _ time_t /* Avoid repeated Definitions Time_t */Typedef long Time_t ;/* Time Value Time_t is the alias of a long integer */# endif although time_t is actually a long integer, to a certain day in the future, from a time point (usually January 1, 1970 00:00:00) by that time, the number of seconds (that is, the calendar time) exceeds the range of the number that can be expressed by a long integer. What should I do? For a value of the time_t data type, the time it represents cannot be later than January 18, 2038. To represent a longer period of time, Some compilers introduce 64-bit or even longer integer numbers to save the calendar time. For example, Microsoft uses the _ time64_t data type in Visual C ++ to save the calendar time, and uses _ time64 () function to obtain the calendar time (instead of using the 32-bit time () function), you can use this data type to save January 1, 3001 00:00:00 (excluding this time point) the time before. In the time. h header file, we can also see some functions, all of which are functions of the time_t parameter type or return value type:
Double difftime (time_t time1, time_t time0 );
Time_t mktime (struct TM * timeptr );
Time_t time (time_t * timer );
Char * asctime (const struct TM * timeptr );
Char * ctime (const time_t * timer ); In addition, time. H also provides two different functions to convert the calendar time (an integer expressed in time_t) to the time format that we usually see separately displaying year, month, day, hour, minute, and second. TM: struct TM * gmtime (const time_t * timer ); Struct TM * localtime (const time_t * timer); by reading msdn, we can know the value of the time point in Microsoft C/C ++ 7.0 (value of the time_t object) the number of seconds that have elapsed since 00:00:00, January 1, December 31, 1899 to this time point, microsoft C/C ++ of other versions and Visual C ++ of all different versions calculate the number of seconds that have elapsed since 00:00:00, January 1, January 1, 1970 to this time point.