linux function of time

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_37597675/article/details/92838529

1. time () function to get the current time

With the structure: time_t (second form)
Usage: time_t time (time_t * t) ;
This function returns the current elapsed counted from 0:00:00 AD UTC time from January 1, 1970 is the number of seconds . If t is not a null pointer, the function also returns the value stored in the pointer memory t

2.localtime () time getting minutes and seconds format

With the structure: tm (date when minutes and seconds form)
Usage: struct tm * localtime (const time_t * timep);
secondary function will in 1970 to the current number of seconds into the time every minute form

3.gettimeofday () Gets the local time through the city after conversion

With the structure: timeval (seconds, microseconds form), which the second format is time_t
Usage: int gettimeofday (struct timeval * tv , struct timezone * tz);
change the function returns the number of seconds after the urban calibrated, and may be exactly subtle.

timeval {struct
time_t the tv_sec; / * seconds The (second) /
suseconds_t tv_usec; /
microseconds (sec) * /
};

struct timezone {
int tz_minuteswest; /* minutes west of Greenwich /
int tz_dsttime; /
type of DST correction */
};

Guess you like

Origin blog.csdn.net/weixin_37597675/article/details/92838529