I. chicken ribs
UTC, Coordinated Universal Time, coordinates world time, is the well-known Greenwich Mean Time (GMT)
Calendar time: indicates the calendar time. The so-called calendar time is the time represented by "the number of seconds passed by a standard time point (such as on January 1, January 1, 1970 )."
Ii. Time Programming
1. Obtain the calendar time: time_t time (time_t * tloc );
How to use:
(1) the header file must be introduced: # include <time. h>
(2) time_t. The prototype is typedef long time_t.
(3) obtain the number of seconds that have elapsed since January 1, January 1, 1970.
(4) If the time parameter is not null, this function can return the result to the variable pointed to by tloc.
2. Time conversion:
(1) struct TM * gmtime (const time_t * timep );
(2) struct TM * localtime (const time_t * timep)
How to use:
(1) convert the calendar time to grrnwich time (GM) Greenwich Mean Time, and save the result to the TM struct.
(2) convert the calendar time to the local time and save the result to the TM struct.
(3) view the true colors of the TM structure:
Struct TM {int tm_sec; // The second value int tm_min; // The minute value int tm_hour; // The Hour value int tm_mday; // The day of the month int tm_mon; // The Nth month of the current year int tm_year; // tm_year + 1900 = which year int tm_wday; // the nth day of the week int tm_yday; // the nth day of the current year int tm_isdst; // Daylight Saving Time}
3. Time display function:
(1) convert the time in TM format to a string, such as sat Jul 30 08:43:03 2005
Char * asctime (const struct TM * TM );
(2) convert the calendar time to a string of local time, for example, Jul 30 08:43:03 2005
Char * ctime (const time_t * timep );
4. Obtain the current time function: int gettimeofday (struct timeval * TV, struct timezone * tz );
How to use:
(1) obtain the number of seconds and microseconds that have elapsed since this morning, and save the result to the timeval structure, it is often used to calculate the time consumption and execution time of events.
(2) structure of timeval:
Stuct timeval {
Int TV _sec; // number of seconds
Int TV _usec; // a subtle number
}
5. Sleep functions:
(1) Enable the program to sleep for seconds: Unsigned int sleep (unsigned int seconds );
(2) program sleep USEC microseconds: void usleep (unsigned long USEC );