Linux Application Development-time programming
Time Type
World Standard Time: GMT
Calendar time: Number of seconds since 1970-1-1
Two time functions
1 Get Calendar Time
Name of function
Time
Function prototype
time_t time (time_t *t)
function function
Time from January 1, 1970, units in seconds
Owning header file
#include <time.h>
return value
The second speed of the successful return time
Failed return-1
Parameter description
Save return value
2 getting GMT
Name of function
Gmtime
Function prototype
struct TM *gmtime (const time_t *TIMEP)
function function
Convert calendar time to world standard Time
Owning header file
#include <time.h>
return value
Successful return time
Failed return-1
Parameter description
TIMEP is the address of the calendar time
3 Get local time
Name of function
LocalTime
Function prototype
struct TM *localtime (const time_t *TIMEP)
function function
Convert calendar time to local time
Owning header file
#include <time.h>
return value
Successful return to local time
Failed return-1
Parameter description
TIMEP is the address of the calendar time
4 Displaying the time in string mode
Name of function
Asctime
Function prototype
Char *asctime (const struct TM *tm)
function function
The time that the standard time is converted to a string display
Owning header file
#include <time.h>
return value
Successful return string pointer holds the string time
Failed return-1
Parameter description
parameter is a struct-body pointer of standard Time
5 Get High precision time
Name of function
Gettimeeofday
Function prototype
int gettimeofday (struct timeval *tv, struct timezone *tz);
function function
Get high-precision time
Owning header file
#inlclude <sys/time.h>
return value
Successful return 0
Failed return-1
Parameter description
TV saved from 1970-1-1-0 to now experience the number of seconds and microseconds
Tzone is usually null
Linux application development-time programming