C Reference function time()
Usage of time():
time_t time ( time_t * ptr_time );
Parameters:
ptr_time is a pointer to an object of type time_t. In this object the time value is stored.
It is also allowed to fill in a null pointer, but the a time_t object is still returned by the function time().
Return Value:
The current calendar time as a time_t object.
If the argument is not a null pointer, the return value is the same as the one stored in the location pointed by the argument.
If the function time() could not retrieve the calendar time, it will return a -1 value.
Explanation:
Return the current calendar time as a time_t object.
If the argument is not a null pointer, the value is also set to the object pointed by ptr_time.
Source code example of time():
#include <stdio.h>
#include <time.h>
int main ()
{
time_t in_seconds;
in_seconds = time (NULL);
printf ("%ld hours since January 1, 1970,
EPOCH time!", in_seconds/3600);
return 0;
}
Output example of the program above:
333350 hours since January 1, 1970, EPOCH time!