Get calendar time
We can use the time () function to obtain the calendar time. Its prototype is:
Time_t time (time_t * timer );
If you have already declared the timer parameter, you can return the current calendar time from the timer parameter, or return the current calendar time from a time point (for example: january 1, 1970 00:00:00) the number of seconds until now. If the parameter is null (NUL), the function returns the current calendar time only by returning the value. For example, the following example shows the current calendar time:
# Include "time. H"
# Include "stdio. H"
Int main (void)
{
Struct TM * PTR;
Time_t lt;
Lt = Time (NUL );
Printf ("the calendar time now is % d \ n", LT );
Return 0;
}
The running result is related to the current time. The running result is:
The calendar time now is 1122707619
1122707619 is the calendar time when I run the program. That is, the number of seconds from January 1, 1970 00:00:00 to this time point.