C library functions - time ()
description
C library functionstime_t time (time_t * seconds) to return from epoch Epoch (1970-01-01 00:00:00 UTC) the elapsed time in seconds.Ifseconds is not empty, the return value is also stored in the variable in seconds.
statement
Here is the declaration time () function.
time_t time(time_t *t)
parameter
- seconds - This is a pointer to an object of type time_t pointer for values stored in seconds.
return value
In time_t object returns the current calendar time.
Examples
The following example demonstrates the time () function is used.
#include <stdio.h> #include <time.h> int main () { time_t seconds; seconds = time(NULL); printf("自 1970-01-01 起的小时数 = %ld\n", seconds/3600); return(0); }
Let's compile and run the above program, which will result in the following:
自 1970-01-01 起的小时数 = 373711